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

fix(useLocalStorage): state change on first mount #1972

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

fix(useLocalStorage): state change on first mount #1972

wants to merge 1 commit into from

Conversation

adesurirey
Copy link
Contributor

Description

Fixes a regression introduced in fdd1b23 where useLocalStorage updates it state during first mount leading to an unwanted re-render. To avoid that I replaced useLayoutEffect by useUpdateEffect and added a test that ensure we only read the storage once on first mount.

closes #1970

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as before)

Checklist

  • Read the Contributing Guide
  • Perform a code self-review
  • Comment the code, particularly in hard-to-understand areas
  • Add documentation
  • Add hook's story at Storybook
  • Cover changes with tests
  • Ensure the test suite passes (yarn test)
  • Provide 100% tests coverage
  • Make sure code lints (yarn lint). Fix it with yarn lint:fix in case of failure.
  • Make sure types are fine (yarn lint:types).

@defunctzombie
Copy link

@adesurirey anything holding back this fix?

@adesurirey
Copy link
Contributor Author

@defunctzombie no just waiting to be reviewed and merged

/cc @xobotyi

@xobotyi
Copy link
Contributor

xobotyi commented Jun 9, 2021

@adesurirey i'm no more collaborator =)
I've strated my own project wher i can control anything except from prs merge 🙃

https://github.com/react-hookz/web

@adesurirey
Copy link
Contributor Author

@xobotyi so react-use is definitely dead?

@xobotyi
Copy link
Contributor

xobotyi commented Jun 9, 2021

@adesurirey presumably - yes.

I've explained everything here: #1974

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

State change regression for useLocalStorage during first mount
3 participants