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

refactor(multiline-text-input): use hooks & expose useCollapsible hook #966

Merged
merged 12 commits into from
Jul 29, 2019

Conversation

montezume
Copy link
Contributor

Summary

Refactors MutilineTextInput to use hooks, and exposes a new useCollapsible hook.

@@ -0,0 +1,12 @@
import React from 'react';

Copy link
Contributor

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.

Copy link
Member

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

Copy link
Contributor Author

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) => {
Copy link
Member

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... 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emmenko emmenko force-pushed the ml-multiline-text-input-hook branch from f58729e to 708783b Compare July 29, 2019 09:04
ControlledCollapsible.propTypes = collapsiblePropTypes;

const UncontrolledCollapsible = props => {
const [isOpen, toggle] = useToggleState(!props.isDefaultClosed);
Copy link
Member

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

@emmenko emmenko merged commit 3c3d712 into master Jul 29, 2019
@emmenko emmenko deleted the ml-multiline-text-input-hook branch July 29, 2019 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants