`onExpandedChange`: event.target is always null
See original GitHub issueWhat version of React-Table are you using?
6.8.0
What bug are you experiencing, or what feature are you proposing?
I’m trying to use the onExpandedChange
callback property on ReactTable
. The documentation says that the function signature looks like this: onExpandedChange={(newExpanded, index, event) => {...}}
. However, the event.target
property is always returning as null
for me.
I see a warning in the developer console suggesting I use event.persist()
to keep event objects from being nullified after being used but even putting that function call at the top of the callback doesn’t seem to change anything.
Use https://codesandbox.io/s/X6npLXPRW (by clicking the “Fork” button) to reproduce the issue.
https://codesandbox.io/s/nkl45jxkwj
What are the steps to reproduce the issue?
- Set a column to have its
expander
property totrue
, enabling expanded rows on the table. - Set your
SubComponent
to something. - Give
ReactTable
aonExpandedChange
callback function with all three arguments. - Use
event.persist()
. console.log(event.target)
- See
null
in the console when we expected to see the event target.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
onExpandedChange : event.target is always null #836 - GitHub
I'm trying to use the onExpandedChange callback property on ReactTable . The documentation says that the function signature looks like this: ...
Read more >Event target is null inside functional setState - Stack Overflow
If I uncomment the first line inside handleInputChange function, where I store text box value inside val variable, it works well. Ideas why?...
Read more >event.target of lightning-button empty
I am baffled. event.target looks like an empty structure, but querying things like event.target.label and event.target.title just returns values ...
Read more >react-table - npm
Sorting comes built in with React-Table. Click a column header to sort by its accessor. Click it again to reverse the sort. Set...
Read more >Null event properties in a React callback - Ludovico Fischer
event.target is null inside the callback because React recycles events objects for performance reasons: React passes the same Event object for ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I can’t be sure but I suspect the event has to be persisted before the first usage of it. It would be a code change to ReactTable that would need to be tested.
Closing due to issue age. If you think this issue needs to be reopened or if it should be turned into a pull-request, please check the latest version of React-Table for the issue or feature once more and reopen or create a PR if appropriate. Thanks!