December 2019
Intermediate to advanced
474 pages
10h 3m
English
Another way to use actions to add data to the Provider is by using a pattern similar to Flux, which was introduced by Facebook. The Flux pattern describes a data flow where actions are being dispatched that retrieve data from a store and return it to the view. This would mean that actions need to be described somewhere; there should be a global place where data is stored and this data can be read by the view. To accomplish this pattern with the context API, you can use another Hook that is called useReducer. This Hook can be used to return data not from a local state, but from any data variable: