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

feat(usePrevious): reworked the hook, now it is more memory-efficient. #1295

Merged
merged 1 commit into from
Jun 19, 2020

Conversation

xobotyi
Copy link
Contributor

@xobotyi xobotyi commented Jun 15, 2020

Description

Better to use two-variables exchange than useEffect with new
function on each render.

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

Better to use two-variables exchange than `useEffect` with new
function on each render.
@xobotyi xobotyi added the enhancement New feature or request label Jun 15, 2020
@xobotyi xobotyi self-assigned this Jun 15, 2020
@xobotyi xobotyi merged commit f364b32 into master Jun 19, 2020
@streamich
Copy link
Owner

🎉 This PR is included in version 15.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dcporter
Copy link

dcporter commented Jun 24, 2020

Hi, sorry to roll in like this but this PR was a mistake. The useEffect is necessary in cases where React renders multiple times before committing — something that it's within its rights to do, and something that the excellent <React.StrictMode> does on purpose to root out buggy side-effects like this. (Edit: writing up Issue now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants