Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReactJS Reflux using mixins with ES6

How do you solve mixins with reflux using ES6?

Like this:

mixins: [Reflux.listenTo(myStore, "onChange")]
                        ^

Results in error "Unexpected token" with arrow shown above.

React v 0.14.7 Reflux v 0.4.0

like image 314
Amidii Avatar asked Oct 30 '22 07:10

Amidii


1 Answers

Theoretically mixins works for react 0.14 .

They don't work if you use ES6 syntax (especially classes). In ES6 we use high order components instead.

You can't simply replace reflux mixins by some ES6 syntax. You have to find not mixins solution for reflux. There is interesting thread about it :

https://github.com/reflux/refluxjs/issues/225

And there are some links which may help you:

https://www.npmjs.com/package/reflux-provides-store https://www.npmjs.com/package/reflux-state-mixin

Or you can try create high order component from mixins by this component:

https://github.com/timbur/react-mixin-decorator

like image 177
Krzysztof Sztompka Avatar answered Nov 15 '22 06:11

Krzysztof Sztompka