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

Function components #396

merged 4 commits into from Jun 7, 2020

Function components #396

merged 4 commits into from Jun 7, 2020


Copy link

@tcbegley tcbegley commented Jun 6, 2020

This PR refactors class components to function components, which has a couple of benefits:

Along the way I also:

  • Improved auto-dismissal of Alert and Toast. Previously when using the duration prop you could set the component to auto-dismiss after a fixed period of time. However, if you dismissed manually before the time was reached, the timer would not clear, hence if the component was toggled again it would auto-dismiss early.
  • Made dismissal of DropdownMenu when clicking on a child DropdownMenuItem consistent.

Copy link

np-8 commented Jun 7, 2020

Wow this looks cool! To a non-React-expert eyes looks that the code for the React components was simplified greatly.

Copy link
Collaborator Author

tcbegley commented Jun 7, 2020

Yes! It's always been possible to write React components as functions, but until React 16.8 introduced hooks it was not possible for those components to do things like manage internal state. That's no longer true and function components are the new recommended way of doing things. I also much prefer it and agree it's a lot cleaner.

I'm going to upload a prerelease to PyPI shortly in case you want to try it out.

@tcbegley tcbegley changed the title Functional components Function components Jun 7, 2020
@tcbegley tcbegley merged commit b2d2828 into master Jun 7, 2020
2 checks passed
@tcbegley tcbegley deleted the functional-components branch Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants