davidgilbertson/react-recollect

"You are trying to read from the global store" error conceals other errors

davidgilbertson opened this issue · 0 comments

If there is a JSX error, React might throw something like Uncaught Error: Objects are not valid as a React child.

Fine, but this might trigger a read of the Recollect store somewhere, so the user sees this error.

image

But that's only a side-effect of the real error, (note: 2 of 3)

image

So I think switching from throw Error to console.error is the way to go. This applies to "You are modifying the store during a render cycle" too. Something might be writing to the store on a timer, or a network request returns and writes to the store.