Null reference scenario with unkeyed children
See original GitHub issueI found a problem with using ref
on unkeyed children. You can observe the problem here: https://jsfiddle.net/rsm2dxb7/1/
Open the console and click Toggle. You’ll see that the final dom reference being passed is null
, which is wrong because the referenced div is still there.
In the example, the first child is conditionally rendered and the second child is using a ref
. On click, the state changes and the first child is unmounted. The ref callback is called two times in wrong order, so the final reference value is null.
{ header && <div className="header">Header</div> }
<div ref={c=>{
console.log(c);
}}>
Content
</div>
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
C# Children and SubChildren Null Reference Exception
Hi everyone, in one of my scripts I'm getting a null reference exception and I'm trying to figure out why. The console says...
Read more >Unable to get property 'children' of undefined or null reference
I am frequently getting this error as well. This almost always happens as I am saving a new task that was created from...
Read more >Ultimate Guide to JSON Parsing with Swift - Ben Scheirman
This is a guide that will take you through almost any scenario you might encounter when translating JSON representations to your Swift types....
Read more >All labs | Web Security Academy - PortSwigger
Mystery lab challenge Try solving a random lab with the title and description hidden. As you'll have no prior knowledge of the type...
Read more >PacketCable™ Security Specification PKT-SP-SEC-I06-021018
architecture as a point of reference for the remainder of the document. ... [1] B. Schneier, “Applied Cryptography,” John Wiley & Sons Inc,...
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 FreeTop 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
Top GitHub Comments
Essentially duplicate of #857. Although this was raised earlier, looks like the main discussion is in #857. @Rendalf For now unkeyed diff has this issue which cannot be resolved. You can use keyed children if possible.
Related to #1440