Skip to content
Discussion options

You must be logged in to vote

While it may look like favorites is duplicated 3 places, AppState.counter and AppState.profile are computed properties that use AppState.favorites under the hood. This means there's really only a single favorites field in state, and not 3, so there's no way for AppState.favorites, CounterState.favorites, or ProfileState.favorites to ever fall out of sync. They all use the same single field as a backing store under the hood.

There is boilerplate involved in managing these computed sub-sets of state, but it's typically the same amount of code (or less) than equivalent code that manually coordinates state between components.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nicnocquee
Comment options

Answer selected by nicnocquee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants