React makes an app's user interface dependent on its state. Redux moves state that is depended on by multiple components into a centralized store. Together these two technologies ease the burden of creating web apps that have complex and dynamic interfaces. But there's an issue that neither of them solve: sometimes the state lives outside of the app, perhaps managed by a web service.
When an app depends on state that it doesn't have locally, you must first pull the data down from the web service, which you can achieve using fetch
. Once its promise has been fulfilled, you dispatch an action that adds the fetched data to the store. The remote state is now part of the local state.
If the user edits this cached local state by interacting with your app, you issue a POST
or PATCH
request back up to the web service to commit these edits.
Your decide to explore these ideas of working with remote state by writing a client for Unforget. You wrote its web service earlier.