3 ms·
How does one create a reusable component (something I could publish on npm for example) for React + Redux? The component would have to define its own data expec
by MatthewPhillips 11y ago
How does one create a reusable component (something I could publish on npm for example) for React + Redux? The component would have to define its own data expectations, so the actions and reducers would have to be defined by the component. How would you do this, given your folder structure (which I think is very common in Redux/React apps)?
- iLoch 11y agoGenerally you don't actually use Redux in your component. Instead, you'd expose the action creators required by your component. Then the user has to make sure that the new state created from your actions gets back to your component via props. This is a common behaviour I've observed, anyway.