Q: Does Fluxxor require React?
A: Fluxxor works great with React, and if you want to use the mixins, you will of course need React, but Fluxxor has no dependency on React itself.
Q: Why does Fluxxor.FluxMixin
constantly throw an error?
A: Fluxxor.FluxMixin
is a function that takes React as a parameter and returns the associated mixin:
var FluxMixin = Fluxxor.FluxMixin(React);
React.createClass({
mixins: [FluxMixin],
// ...
});
Q: How do I deal with asynchronous operations in stores?
A: Dispatches to stores are always synchronous, but stores can perform asynchronous operations. At the end of the async call, the store can dispatch a separate action that represents the availability of the asynchronously-obtained data. See Dealing with Asynchronous Data for more details.
Q: Why does dispatching an action while another action is in progress throw an error?
A: Fluxxor prevents cascading updates where one action triggers another, and so on. See What is Flux and Flux Application Architecture for more information on Flux.
Q: Why am I getting an error saying that I can't dispatch an action while another action is being dispatched if I'm dispatching an action from componentWillMount
or componentDidMount
?
A: React automatically batches updates when they're triggered from inside its synthetic event system (e.g. from an onKeyPress
or onClick
handler), but otherwise you have to batch them yourself. See the "Batched Updates" section of Using with React page for a solution to this problem.
Q: Why is Fluxxor throwing an error saying an action is already being dispatched when I'm sending an action from an asynchronous operation?
A: Some libraries will sometimes call callbacks on the same tick, for example if data is cached. You can wrap the action dispatch call in a setTimeout
to ensure the function is asynchronous. For bonus points, notify the author of the offending library that their asynchronous callbacks are sometimes synchronous.
Q: Why do I see a warning that says "possible EventEmitter memory leak detected"?
A: This warning is built in to the Node.js EventEmitter to help avoid accidentally leaking handlers. If you know you're not actually leaking and you want to suppress this warning, you can call setMaxListeners(n)
on your store (you can use a value of 0
for unlimited).
As of version 1.4.2, Fluxxor uses EventEmitter3 instead of the built-in Node.js EventEmitter, which should resolve this issue.