2 ms·
It's actually fairly similar in an idiomatic Redux app. "Lets say you have a User. You want to display information about the user in three different places in
by Lazare 11y ago
It's actually fairly similar in an idiomatic Redux app.
"Lets say you have a User. You want to display information about the user in three different places in the user interface. With Redux this is simple. You have a single User store and three different containers that each receive the source model as inputs, transform it using connect/reselect, and then passes it on, along with action creators to change the data, to the underlying components. Any change in the User model propagates down to through the containers to the components. If you edit the user from one component it updates the store and then the components. Changes then cascade back down so that all three containers update if needed. Very simple."
Sounds familiar, no? The big difference is that instead of editing the data you're passed directly, and having it magically update everywhere, you're passed an immutable User object and an updateUser() function, which you call to edit the object.
But the same distinction between your data, the view, and the intermediate layer that transforms the data for the view is very much present.