SearchInput onChange callback has a null event.target
See original GitHub issueDescription
Moving this to the callback of setState seems to have the side-effect of causing event.target to be null for the onChange callback. So something like
<SearchInput
onChange={e => console.log(e.target.value)}
/>
throws TypeError: Cannot read property 'value' of null
Here’s a stack overflow I found on related to the issue: https://stackoverflow.com/questions/51256318/issue-of-using-e-target-value-in-react-setstate-function
Versions
fundamental-react: latest fundamental-styles: latest
NOTE: Where applicable, please include uncropped screen captures.
DISCLAIMER: After triaging an issue, the fundamental-react team will see if it can be reproduced or confirmed. If more information is needed, the fundamental-react team will contact the author. Any issues awaiting responses from the author for more than 7 days will be closed. The author can re-open the issue at a later time if they can present the requested information.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
If we use
event.persist();
, we would be effectively disabling a React optimization for events. Moreover,this problem is present in all components where the event handlers are passed in this manner. Using event.persist() for all the components does not seem to be a good idea. A simple solution would be to convert these components to ForwardRefs and the developer can access the event.target through ref,leaving the event optimization as is. @jbadan Please advice.I did verify that adding
event.persist();
does fix the problem