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

External validation misrender #154

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

andybenedict
Copy link

@andybenedict andybenedict commented Jul 7, 2022

In reference to issue #130

It was the check we discussed, but not for the reason I thought.

Since migrating from componentWillReceiveProps to componentDidUpdate the initial state update on the first keypress is being processed before the isDebouncing flag is set.

Previously, the debouncing flag was getting set before the render occurred, but now it is happening earlier, so I expect you were experiencing difficulty and stuttered renders.

In order to combat hitting a check that the isDebouncing flag was intended to avoid, an additional check was added that causes the undesirable rendering behavior.

To mitigate, I set it up to conditionally set the isDebouncing flag (if denouncing is necessary when calling this.notify) before we set the initial state.

As far as I can tell, all of the current examples appear to work perfectly and skipping that extra render appears to slightly improve performance as well. (Though I'm no expert in profiling react apps 😀). I also added another example to demonstrate using the input in the context of external validation that can correct the value.

When migrating from componentWillReceiveProps to componentDidUpdate
the initial state update on the first keypress was being processed
before the isDebouncing flag was set.

In order to combat hitting a check that the isDebouncing flag was
intended to avoid, an additional check was added that causes
undesirable rendering behavior in certain cases where the internal
state can get out of sync with the external values, especially
during external validation that might want to update the component's
value prop.

To mitigate, we need to set the isDebouncing flag before we set the
initial state.
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.

1 participant