3 ms·
Also, if you want to focus on how components in React get their data, that's pretty simple. They just subscribe to it. If you wanted to render a list of accoun
by JaRail 9y ago
Also, if you want to focus on how components in React get their data, that's pretty simple. They just subscribe to it.
If you wanted to render a list of accounts, you could have a couple levels.
At the top, you have an account lists component. It gets a list of accountIds from a global data store (in redux). Then it outputs something like this:
<List>
<Account id="1" />
<Account id="2" />
</List
The Account components then pull info from Redux about whatever they need to render whatever account they're responsible for.
Each component registers a listener/callback with Redux when its first instantiated. So if the balance of an account changes, it's listening for that change. The change triggers your callback, that triggers a fresh render(). Then the next render() pass pulls the updated account balance with its next pass, etc.
- mkirklions 9y agoredux is going to solve my problems, very excited to get this tip.