-
Notifications
You must be signed in to change notification settings - Fork 26
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
refactor(multiline-text-input): use hooks & expose useCollapsible
hook
#966
Conversation
@@ -0,0 +1,12 @@ | |||
import React from 'react'; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we put this into components? Would a hooks folder be more apt?
We could also call it useToggle I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree with Tobi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya good call 🎈
@@ -0,0 +1,12 @@ | |||
import React from 'react'; | |||
|
|||
const useCollapsible = (defaultValue = true) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m wondering if we should name it like this or just something like useToggleState
, because the hook itself does not do any “collapsible” work... 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f58729e
to
708783b
Compare
ControlledCollapsible.propTypes = collapsiblePropTypes; | ||
|
||
const UncontrolledCollapsible = props => { | ||
const [isOpen, toggle] = useToggleState(!props.isDefaultClosed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I split the rendering into two components (controlled / uncontrolled) to fix the "conditional" rendering of the hook in the main component
Summary
Refactors
MutilineTextInput
to use hooks, and exposes a newuseCollapsible
hook.