question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`onExpandedChange`: event.target is always null

See original GitHub issue

What 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?

  1. Set a column to have its expander property to true, enabling expanded rows on the table.
  2. Set your SubComponent to something.
  3. Give ReactTable a onExpandedChange callback function with all three arguments.
  4. Use event.persist().
  5. console.log(event.target)
  6. See null in the console when we expected to see the event target.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gary-menzelcommented, Apr 5, 2018

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.

0reactions
tannerlinsleycommented, May 24, 2018

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found