Looking for Reakit's successor?Visit Ariakit
Skip to main content
Reakit
DocumentationNewsletter
GitHub

Managing state

Reakit components are pretty much stateless, which means that they need props to be passed in so as to modify their state.

DisclosureContent, for example, is a generic component that can be disclosure or visible based on props:

Content

You can pass your own state to control it:

Content

#State hooks

As a convenience — and because some states need more complex logic —, Reakit provides state hooks out of the box. They receive some options as the initial state and return options needed by their respective components.

The returned options can be passed as props directly to the components, or used separately to access, update and/or extend the state.

Content

#Lazy initial state

For lazy initialization, you can pass a function that returns the initial state:

#Shared state

If you need to share state between multiple components within your app, you can use Constate:

Content