-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tabs: Expose easier way to access current tab id. #606
Comments
Interesting… I wonder if you can expand a bit more on why do you have the need to know it outside the tabs UI? Before adding new APIs I'd rather dig deeper on the supposed need for it. |
I can imagine ways to overcome that situation without changing our API, and I was about to propose some ideas, but I realize that they all make assumptions about how you manage the state in those listings, and it could all make you have to find workarounds. I can understand, for instance, how you could be handling all your data right in the body of the component that renders the entire So yes, we could/should explore a way to make the UncontrolledWhat we have today <Tabs>
{/* tabs and tabs panels inside */}
</Tabs> Controlledconst [selectedTab, setSelectedTab] = React.useState('initial-state')
return (
<Tabs selectedTab={selectedTab} onChange={setSelectedTab}>
{/* tabs and tabs panels inside */}
</Tabs>
) |
That works for me 👍🏻 |
@scottlovegrove FYI, you can now use the tabs as a controlled component using the |
🚀 Feature request (I think)
Motivation
Using the new tabs components, I still found myself needing to know what the currently selected tab id was. I know under the hood these components are using the Reakit tabs, and that does offer access to that via the
useTabState
hook, but this isn't available (I don't think) when using the Reactist tabs.Example
What I've ended up having to do is work around it like this
Having the
TabAwareSlot
is fine for if you're wanting to display something in the UI, but it's not ideal if you just need the tab id.Possible implementations
I think maybe exposing the
useTabState()
hook could help remedy this, or a Reactist variant of this hook.The text was updated successfully, but these errors were encountered: