The State of React’s State in 2019
In the past few years, the approach to application state in React has been constantly shifting. Local component state has been complemented with global state management solutions like ‘react-redux’ or ‘mobx-react’. The introduction of GraphQL libraries like Apollo brought new approaches to API caching (at least for GraphQL). With the release of React 16.3, the reworked Context API has been finally declared stable, adding a viable option for small and simple global states.
As a part of the forthcoming React 16.7, hooks will allow for easier use of local state as well as context in function components. Existing libraries are already discussing new hook-compatible APIs that will change the way we are using them. Furthermore, the upcoming ‘suspense’ mechanism is bound to spawn the birth of at least a few new libraries with focus on “perceived local” data fetching and caching.
Unfortunately, there is no “one size fits all” solution when evaluating these approaches. This talk highlights the different types of state occurring in modern React applications and give recommendations on how to approach them with the tools currently available, with an outlook on the near future.
Lenz Weber has been working in web development and DevOps for 15 years. He has been working for Mayflower since 2016, shifting his focus from backend to frontend, always challenging himself and experimenting with the tools at his disposal. If he’s not doing web development, he reads up on security (special focus on passwords), experiments with NixOS, or interacts with random Open Source Projects on GitHub.
If you want to get into contact, a tweet is the best idea. Find him on Twitter @phry.