Uh oh!
There was an error while loading. Please reload this page.
Creating element with ref in constructor does not throw error in dev mode (#9635) - #10025
Conversation
iansu
commented
Jun 22, 2017
I've managed to fix this bug but, to be perfectly honest, I don't fully understand what's going on here. Previously when constructing a component in dev mode |
gaearon
commented
Jun 23, 2017
Can you also check if this ever worked with previous versions of React? Specifically 0.13 and 0.14? |
@gaearon I had a bit of trouble getting 0.13 installed but I think I got it working enough to run the tests. It looks like the error is thrown in 0.13 when |
| ReactTestUtils.renderIntoDocument(<RefTest />); | ||
| }).toThrowError(); | ||
| __DEV__ = originalDev; |
There was a problem hiding this comment.
I think this should be in a finally block so that it happens regardless.
| expect(function() { | ||
| ReactTestUtils.renderIntoDocument(<RefTest />); | ||
| }).toThrowError(); |
There was a problem hiding this comment.
It would be nice to assert a specific error message here. I don't think Fiber currently has a nice message in this case. Can you look into it?
There was a problem hiding this comment.
I originally tried checking for the specific error message. I copy/pasted the message but it said actual vs. expected message didn't match, even though they appeared identical. I'll give it another try.
iansu
commented
Jun 29, 2017
I've updated the tests to check for the specific error message. This breaks the tests in Fiber since the error message is different. @gaearon you're correct that this error does not have a nice message in Fiber, it just results in a |
iansu
commented
Jun 29, 2017
I have a potential fix for this in Fiber. Currently on line 559 of |
@gaearon I've made the requested changes here and pushed a commit but I'm not sure if there's some way I can request another review or otherwise confirm that I've made the changes. I assume you've just got your hands full but I want to make sure you're not waiting on me. Also let me know about the Fiber fix in my previous comment. |
gaearon
commented
Aug 12, 2017
Sorry this slipped through the cracks. We were focused on getting 16 beta out. Can you rebase on master? I think the change to Fiber code is now not necessary because we have a better check there. |
iansu
commented
Aug 12, 2017
I rebased upstream/master into my branch and now it's showing all the commits that have happened since then as part of my pull request. I'm not exactly sure how to fix that. 😬 Looking at |
I tried running the tests I added for this issue with the version of Also, no need to apologize, I understand that React 16 is high priority. I want it to be released too. 😀 UPDATE: It looks like the error is being caught but with a different error message which is why the tests are failing. |
iansu
commented
Aug 12, 2017
I've reverted the changes in |
gaearon
commented
Aug 14, 2017
The extra commits look weird. Let's just do And then force push. This will turn it into a single commit on top of current master. |
iansu
commented
Aug 14, 2017
|
… Only set ReactCurrentOwner.current in dev mode when the component has no constructor.
iansu
commented
Aug 14, 2017
Done! GitHub was still showing all the commits on the pull request for a minute there and I thought I effed it up again but it looks good now. Thanks for the help Dan! |
gaearon
commented
Aug 15, 2017
Sweet. Thanks. |
… Only set ReactCurrentOwner.current in dev mode when the component has no constructor. (#10025) nhunzaker: I've added an additional line to the ref test that sets the NODE_ENV invironment variable. This allows the test to pass.
… Only set ReactCurrentOwner.current in dev mode when the component has no constructor. (#10025) nhunzaker: I've added an additional line to the ref test that sets the NODE_ENV invironment variable. This allows the test to pass.
… Only set ReactCurrentOwner.current in dev mode when the component has no constructor. (#10025) nhunzaker: I've added an additional line to the ref test that sets the NODE_ENV invironment variable. This allows the test to pass.
… Only set ReactCurrentOwner.current in dev mode when the component has no constructor. (react#10025)
Currently just a failing test to show that this issue does exist. Next step is to fix the issue. See issue #9635.