use react-aria
with other state management library?
#2667
-
I wonder if I can use I guess I don't understand what's the purpose of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
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 actual apps that use your design system components. It won't interfere with any other state management libraries you're using to build your apps. In fact, the users of your design system components won't even be aware of React Stately. The above was just to mention that you could use your own state management library when building your components with React Aria, if you didn't want to use React Stately. Here is an example of a Switch that uses useSwitch, and XState for state management. https://codesandbox.io/s/useswitch-xstate-qijgx?file=/src/App.js |
Beta Was this translation helpful? Give feedback.
You should be able to, as long as the state you pass into the React Aria hook is the correct type.
Example:
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 …