Skip to content
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

[Question] When do we use knobs over control? #12684

Closed
cybervaldez opened this issue Oct 7, 2020 · 3 comments
Closed

[Question] When do we use knobs over control? #12684

cybervaldez opened this issue Oct 7, 2020 · 3 comments

Comments

@cybervaldez
Copy link

I'm new and keep seeing knobs tutorial but I've read we should use control instead, is there any instances when I would prefer this over controls? or is this eventually going to be deprecated.

@shilman
Copy link
Member

shilman commented Oct 7, 2020

controls was introduced in 6.0 to replace knobs. the two areas it falls short currently:

if you don't need either of these immediately, use controls

@cybervaldez
Copy link
Author

controls was introduced in 6.0 to replace knobs. the two areas it falls short currently:

if you don't need either of these immediately, use controls

I'm very interested in the former, conditionally show/hide knobs based on a state.

const [isEnabled, toggleEnabled]= useState(true)

return <>{isEnabled && text('enabledLabel', 'enabled')} {!isEnabled && text('disabledLabel', 'disabled')} <button onClick={()=>toggleEnabled(isEnabled)}>Toggle</button></>

I'm expecting to hide/show enabledLabel and disabledLabel in the knobs panel depending on the state.

@shilman
Copy link
Member

shilman commented Dec 23, 2020

Closing this as dupe to #11984

@shilman shilman closed this as completed Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants