React: Bug: React-17.0.0-rc.0 react-reconciler focusedInstanceHandle crash

Created on 11 Aug 2020  路  9Comments  路  Source: facebook/react

i tried testing the rc with react-three-fiber, it crashed. so tried with a super reduced minimal renderer, here's the link for testing it: https://codesandbox.io/s/reurope-reconciler-forked-wikus?file=/src/App.js:418-492

change the color in line 13 from hotpink to something else and it crashes the reconciler

Screenshot 2020-08-11 at 00 12 46

going through the stack trace it passes focusedInstanceHandle to doesFiberContain, but it is undefined

function commitBeforeMutationEffects() {
  ...
        if (doesFiberContain(nextEffect, focusedInstanceHandle)) {

this now causes trouble in doesFiberContain which checks against null, but not undefined

function doesFiberContain(parentFiber, childFiber) {
  var node = childFiber; // undefined
  while (node !== null) {
    ...
    node = node.return;
Unconfirmed

Most helpful comment

All 9 comments

I think if you return null from prepareToCommit that would fix it.

(Maybe this is a good argument to make the check looser.)

indeed that fixed it! are there any other places it needs null?

looks better now in r3f, too. it started to run - for a while - then it wipes out the complete content of a useRef, where i keep my state. will make a new new issue if im certain im not the one causing it.

Not aware of other places. If you narrow it down, file for sure!

@gaearon turns out this was related to https://reactjs.org/blog/2020/08/10/react-v17-rc.html#potential-issues (the new useEffect timing). some thing wanted to rely on state, which was disposed earlier.

You can useLayoutEffect if being sync is important.

I think if you return null from prepareToCommit that would fix it.

That's prepareForCommit not prepareToCommit :) I just blindly copy-pasted it and was really sad, when it didn't work. Luckily I double-checked the name and saw the problem ... and now it works! Thanks @gaearon.

@gaearon cool thanks! Already bookmarked :)

Was this page helpful?
0 / 5 - 0 ratings