So I took the react course here , and now I’m at redux.
I managed before to run react code in a jsx-fiddle , but have had no luck so far ?
I’m getting a ‘redux.createStore is not a function’ error?
There isn’t a function called Redux.createStore: you have called your class Redux, so when you try to run createStore, it recursively calls your class and looks for a createStore static method, which does not exist.
If you call your functions/classes the same names as the library you’re trying to use, things will not work as expected.
It’s easy done. There’s a more fundamental issue here though, the store doesn’t go in a component, you set it up outside the components then use the react-redux libabry to hook it into them
I placed the store outside of the class , right above the class, it works too so that should be correct? Or should these lines be in another function or class?
So I have this now:
Yeah it takes a little while grok. It doesn’t make any sense to do it like that: basically the store needs to be available everywhere in the app, putting it within a component that isn’t the <Provider> that react-redux provides means a. Atm it’s only available to that component, which defeats the point and b. if you manually passed down the dispatch function to every child to get around a, you’d also have to hook up the listeners on every single component you passed it to (this being what react-redux does).