Skip to content

use react-aria with other state management library? #2667

Answered by reidbarber
fnick851 asked this question in Q&A
Discussion options

You must be logged in to vote

You should be able to, as long as the state you pass into the React Aria hook is the correct type.

Example:

import {useSwitch} from '@react-aria/switch'
import {useMyCustomToggleState} from 'whatever-package';

function Switch(props) {
  let state = useMyCustomToggleState(props); // instead of useToggleState. Works as long as it's return type is ToggleState
  let ref = React.useRef();
  let {inputProps} = useSwitch(props, state, ref);
...

I think resolving these types may be too much work to make it worth it though, but I would be curious to hear what your use case is.

Edit:

Also to clarify, React Stately is intended to provide state management for your design system components, not your …

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@fnick851
Comment options

@AlexGalays
Comment options

@snowystinger
Comment options

@reidbarber
Comment options

@AlexGalays
Comment options

Answer selected by reidbarber
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants