You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, this internal state-keeping causes problems when we attempt to control Tabs from the outside using the value prop. It would be more correct to call the value prop a defaultValue since useState does not reload the initial value from props on rerender.
The way I see it, there are couple ways forward with this:
Add a useEffect hook with a dependency on the value prop to update the internal state. (Not a huge fan of this solution)
Remove the internal state entirely, and let the user control the state themselves using the exposed onChange prop.
I'll leave the solution up to whoever wants to tackle this. Open to other ideas as well!
The text was updated successfully, but these errors were encountered:
I looked into it and I think that handling the state outside of the <Tabs> component through the value and onChange props would make more sense and feel more intuitive.
chargome
added a commit
to chargome/react-daisyui
that referenced
this issue
Oct 5, 2022
Our current
<Tabs>
parent component maintains the active tab value in auseState
and passes the value along to all of the child<Tab>
components.https://github.com/daisyui/react-daisyui/blob/main/src/Tabs/Tabs.tsx
However, this internal state-keeping causes problems when we attempt to control Tabs from the outside using the
value
prop. It would be more correct to call thevalue
prop adefaultValue
since useState does not reload the initial value from props on rerender.The way I see it, there are couple ways forward with this:
useEffect
hook with a dependency on thevalue
prop to update the internal state. (Not a huge fan of this solution)onChange
prop.I'll leave the solution up to whoever wants to tackle this. Open to other ideas as well!
The text was updated successfully, but these errors were encountered: