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: Move SearchInput and SideNav callbacks outside of setState. #1165

Merged
merged 2 commits into from
Aug 17, 2020

Conversation

skvale
Copy link
Contributor

@skvale skvale commented Aug 13, 2020

Description

If the callback with an event is included in the callback of setState the event is not persisted and we lose the event.target
You will see warnings like this:

Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property `target` on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist(). See https://fb.me/react-event-pooling for more information.
    in SideNav (created by storyFn)
    in provider (created by Provider)
    in div (created by Provider)
    in Provider (created by storyFn)
    in storyFn
    in ErrorBoundary

“Warning: This synthetic event is reused for performance reasons”
This warning is triggered when we try to access to a React synthetic event in an asynchronous way. Because of the reuse, after the event callback has been invoked the synthetic event object will no longer exist so we cannot access its properties.

BREAKING_CHANGE: If consumers had used the SearchInput like the test, where it was expecting the input's ref value to be updated inside of the callback, this is a breaking change, but that seems like a non-react way to handle changes

fixes #629

If the callback with an event is included in the callback of setState the event is not persisted and we lose the event.target
@skvale skvale self-assigned this Aug 13, 2020
@netlify
Copy link

netlify bot commented Aug 13, 2020

Deploy preview for fundamental-react ready!

Built with commit af87be0

https://deploy-preview-1165--fundamental-react.netlify.app

@skvale skvale changed the title fix: SearchInput and SideNav callbacks outside of setState. fix: Move SearchInput and SideNav callbacks outside of setState. Aug 13, 2020
@skvale skvale merged commit e1127b1 into master Aug 17, 2020
@skvale skvale deleted the fix/callback-events-are-null branch August 17, 2020 15:43
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.

SearchInput onChange callback has a null event.target
3 participants