NewOldMax / react-form-validator-core

Core validator component for react forms
MIT License
94 stars 44 forks source link

Persist synthetic event #46

Closed ChiralMichael closed 5 years ago

ChiralMichael commented 5 years ago

Persist the synthetic event so that it is accessible when the onClick callback is bubbled. See https://reactjs.org/docs/events.html#event-pooling

ChiralMichael commented 5 years ago

The latest change blew up my code when I tried to access the event, since it had been recycled. React outputs a helpful warning to the debug console when accessing properties on a recycled synthetic event, which illustrates the problem exactly.

NewOldMax commented 5 years ago

Hi, can you reproduce your issue at https://codesandbox.io/s/new ?

ChiralMichael commented 5 years ago

I have a repro at https://codesandbox.io/embed/yvj1mj79l1 . Note the message in the console when you hit "submit". The upshot is that all properties on the event are nullified and hence unusable since the event is being bubbled from within a promise callback, after it has been recycled.

"This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property nativeEvent 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."

ChiralMichael commented 5 years ago

How is this looking? Do you need anything else from me?

NewOldMax commented 5 years ago

@ChiralMichael sorry, I just don't have time to process this right now

ChiralMichael commented 5 years ago

@NewOldMax Thanks for getting back to me. I'll have to maintain a fork or else find another solution. Plan to fork/publish my own package for the time being. Feel free to close this request or leave open as you wish.

ChiralMichael commented 5 years ago

scratch that, I just locked to 2.0.3 for react-material-ui-form-validator. That will work for a while at any rate

NewOldMax commented 5 years ago

@ChiralMichael please check the 2.0.8 version

ChiralMichael commented 5 years ago

Thanks so much, this is a huge help!