`
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.
My plan is to refactor Timo to use each of these libraries in upcoming monthly posts. I hope that doing so will help us get a better idea on what each of these libraries are like to use. But now I realize that Timo does not have a lot of client state. So in next month's post, I will clean up Timo's data fetching using Tanstack query and add some more features to give us more client state.