`
class Story extends React.Component { ... }
// Higher order component (HOC) that wraps `<Story>`
var StoryContainer = Relay.createContainer(Story, {
fragments: {
// Define a fragment with a name matching the `story` prop expected above
story: () => Relay.QL`
fragment on Story {
text,
author {
name,
photo
}
}
`
}
})
The next major change to state management libraries came from the introduction of React Hooks in 2019. Hooks provided a way to share stateful logic across components. Until now, state management used Higher order components (HOCs) to interact with components (e.g. Redux's connect HOC). Many eventually switched to using Hooks but several Hook-centric alternatives also appeared. (e.g. Zustand, Recoil, Jotai and Valtio) Soon after, the Redux team also introduced Redux toolkit to help developers use Redux with less boilerplate.
With that brief history lesson out of the way, here are the state management libraries that I want to take a closer look at.
I chose these libraries because they are actively being used by the community and because each of them has different philosophies and patterns.
In upcoming monthly posts, I will refactor Timo to use each of these libraries. I hope that doing so will help us get a better idea on what each of these libraries are like to use. You can sign up for the monthly posts here so that you don't miss the new posts.
But now I realize that Timo does not have a lot of client state. So in next month's post, I will add a few features to Timo to give it more client state. I will also take that as a chance to improve Timo's data fetching logic by using Tanstack query.