5

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

Krzysztof Sztompka
  • 7,066
  • 4
  • 33
  • 48
Amidii
  • 335
  • 2
  • 17

2 Answers2

1

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

Krzysztof Sztompka
  • 7,066
  • 4
  • 33
  • 48
1

Reflux now has a React ES6 API.

See here: https://github.com/reflux/refluxjs#react-es6-usage

Anything v5+ has ES6 capability.

BryanGrezeszak
  • 577
  • 2
  • 8
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/13012847) – DVarga Jul 15 '16 at 08:11
  • I am not posting the entirety of the documentation of the new API to Reflux in an answer. That would be ridiculous, and would likely be outdated soon enough anyway. There is no mixin equivalent to simply switch a line...it's a totally different API leveraging ES6 inheritance. The entirety of that API is what is relevant here, and that should be learned from that page, not from this one. – BryanGrezeszak Aug 24 '16 at 13:29