August 2017
Beginner
374 pages
10h 41m
English
An application might have a mixture of relational data and nonrelational data. There are no hard rules on how to design state, but a common pattern is to organize data by putting it into separate subobjects of the state. For example, we could put data from the backend and UI state into separate subobjects:
{ data: { posts: { ... }, users: { ... }, comments: { ... } }, editedData: { posts: { ... }, users: { ... }, comments: { ... } }, ui: { route: { ... }, ... }, otherData: { ... }}
When existing data is edited, we temporarily store the changes in state.editedData, then synchronize them to the server. Once we get the updated data as a response from the server, we can update the entry in state.data
Read now
Unlock full access