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: Removed infinite loop in AltDateWidget #3518

Merged
merged 1 commit into from
Mar 19, 2023

Conversation

heath-freenome
Copy link
Member

@heath-freenome heath-freenome commented Mar 17, 2023

Reasons for making this change

Fixes #3516 by removing the infinite loop caused by two useEffects() by adding a new state for the value and combining the effects into one

  • Updated AltDateWidget to stash the value in state and combining the two useEffects() into a single effect
    • The effect will call onChange() when the state is ready for change AND it causes a different string than the current value
    • If the lastValue recorded differs from the value, then we record the new value and set the state to it
  • Updated the CHANGELOG.md accordingly

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

Fixes rjsf-team#3516 by removing the infinite loop caused by two `useEffects()` by adding a new state for the `value` and combining the effects into one
- Updated `AltDateWidget` to stash the `value` in state and combining the two `useEffects()` into a single effect
  - The effect will call `onChange()` when the `state` is ready for change AND it causes a different string than the current `value`
  - If the `lastValue` recorded differs from the `value`, then we record the new `value` and set the `state` to it
- Updated the `CHANGELOG.md` accordingly
@heath-freenome heath-freenome merged commit 12b7df1 into rjsf-team:main Mar 19, 2023
@heath-freenome heath-freenome deleted the fix-3516 branch March 19, 2023 19:33
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.

Crash caused by ui-widget alt-datetime when using "Now" button and making changes
2 participants