Using Stylex & accessing state #6119
-
I am working on implementing React Aria Components with Stylex. I am running in to trouble when I need to use "states, selectors, and/or render props" to conditionally render styles. It seems that classname in React Aria Components is ready to accept a function that has access to the state. But I do not see how I can access the same myself. For Stylex, styles are applied by spreading a function onto the element.
As I understand it, when Stylex is run on on this code it returns a prop object of either a classname or a style object.
I'm trying to figure out how I can get something like
I have a repo where I have taken the React Aria Components Tailwind starter kit and converted it into the beginning of a component library. The Button component is the one where I have started converting to Stylex. Any help would be greatly appreciated. Let me know if I can provide any more information. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
It looks like I can add to my component However, it seems as though the RAC Button component is already doing all of this work. Is there a reason why I cannot access the state from there rather than doing it all over again in my component? |
Beta Was this translation helpful? Give feedback.
-
Ah, so I don't want to use isFocusVisible, as that is just a global bool. So, hmm. Tried using a ref, that didn't work. I guess I can use Still plugging away. But by moving on to |
Beta Was this translation helpful? Give feedback.
could you do something like this?