-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to use "Dumb Components" #134
Comments
@kswope in the Counter example this is a dumb component and this one smart. Isn't it here? |
Consider a A To recap:
|
If you put Then you can use Because most components are only interested in a particular slice of the global state (akin to subscribing to a Store), Redux providers function select(state) {
return { counter: state.counter };
}
export default class CounterApp {
render() {
return (
<Connector select={select}>
{({ counter, dispatch }) =>
<Counter counter={counter}
dispatch={dispatch} />
}
</Connector>
);
}
} Now Does this make sense? |
Action creators are just pure functions so they don't interact with anything. Components need to call Stores are just pure functions too so they don't need to be “registered” in the traditional sense, and you can't subscribe to them directly. They're just descriptions of how data transforms. So in that sense they don't “interact” with anything either, they just exist, and are used by the dispatcher for computation of the next state. Now, the dispatcher is more interesting. You pass all the Stores to it, and it composes them into a single Store function that it uses for computation. The dispatcher is also a pure function, and it is passed as configuration to To sum it up: there is a Redux instance at the root of your app. It binds everything together. It accepts a dispatcher (which itself accepts Stores), it holds the state, and it knows how to turn actions into state updates. Everything else (components, for example) subscribes to the Redux instance. If something wants to dispatch an action, they need to do it on the Redux instance. There is no other “interaction” in Redux. |
the previous comment worth a whole section on readme.md or something, |
It would be great if there was more documentation around using Redux without Connectors and Providers -- how to subscribe, unsubscribe and so on, essentially removing some of the magic in favor of explicitness and a fully documented API. |
Agreed. @acdlite is leading the new docs effort in #137, I'm sure he'll consider it! |
Awesome, thanks @acdlite :) The docs for Flummox are great and I'm really rooting for a similar effort to be put into Redux, particularly in exposing some of the internals / patterns around wrappers and data flow. |
+1 to more documentation using Redux without Connectors/Providers, a bit stuck at the moment |
But I guess I'm too dumb to understand how. Do the docs actually show anywhere how stores/actions/dispatcher interact when not using all the magicality of smart components and shortcuts like bindActionCreators. If they don't consider this a request for more documentation.
The text was updated successfully, but these errors were encountered: