react icon indicating copy to clipboard operation
react copied to clipboard

React 15.0.1 Updates causing issues with DOM

Open jbbae opened this issue 10 years ago • 61 comments

Hey, So I'm a fairly new developer who had a working app until version v0.14.8, and just updated to v15.0.1 today. The update did remove a few errors/warnings I was struggling with (so a great relief there), but brought up this issue.

Specifically, the app itself renders fine, with all the pages looking fine (all components, text, etc. in the right places), but is just "frozen" - completely non-functional, not allowing me to click on anything etc.

The error message I see are as follows (from Chrome and Firefox): capture capture2

I back-tracked it to where I could and found this being the part where the "node" is coming off as null: capture3

So I have absolutely no clue what's going on and there seems to be no hint as to what exactly is causing this issue. I will try ripping the app apart and do a thorough debugging, but wouldn't expect much from it (due to my unfamiliarity with development yet...). I really really appreciate the help in advance, and hope that this problem can contribute somewhat to improving the React ecosystem!

jbbae avatar Apr 10 '16 07:04 jbbae

This problem was introduced by using Redux connect on various sub-components, and since this was a critical production feature, we did a quick refactoring to only connect the main component, and now it seems to be working fine.

The problem seems affect media tags when doing batch updates. See my previous stacktrace.

torarnek avatar Jun 28 '16 08:06 torarnek

Unfortunately until somebody can share a reproducing example we will be left guessing as to what it is. It would really help if you could spare a few hours to find a minimal reproducing sample. Hopefully React saved you more than a few hours so that seems fair :-)

gaearon avatar Jun 28 '16 10:06 gaearon

Hey Dan, if I knew how to create a reproducible example I would have definitely made one (you guys deserve it), however in our case only android mobile users with a certain Chrome browser got this issue. I tried to reproduce with the android emulator, but was not able to get the error. So I am sorry about that.

torarnek avatar Jun 28 '16 12:06 torarnek

This is very helpful info, thanks for sharing! Maybe somebody else will be able to use it to publish a case reproducing on Androids.

gaearon avatar Jun 29 '16 00:06 gaearon

Summary

I stopped seeing it in Chrome 50+, and have not been able to reproduce the issue since. I use sentry to track errors in several of my projects. I can see the same audio element issue above occurring for certain users, and have compared the stack traces.

Insight

These users were running Opera 38.0.2220.31 and IE 11.0. They were using Windows 7 at the time. They were all running v15.1.0 of React. Several months of stack traces and no other browser has reported this error. I don't have many mobile web users (native apps), so I wouldn't expect to see those browsers reported (<1%).

Example Stack Trace
TypeError: Cannot read property '__reactInternalInstance$1yks451snh16k09eiy17cik9' of null
  at Object.s [as getClosestInstanceFromNode](/assets/application-eebe52b07353e35ecb012c38735fcf9c.js:123:18949)
  at r(/assets/application-eebe52b07353e35ecb012c38735fcf9c.js:139:26220)
  at i(/assets/application-eebe52b07353e35ecb012c38735fcf9c.js:139:26426)
  at r.perform(/assets/application-eebe52b07353e35ecb012c38735fcf9c.js:124:12191)
  at Object.batchedUpdates(/assets/application-eebe52b07353e35ecb012c38735fcf9c.js:139:26041)
  at Object.i [as batchedUpdates](/assets/application-eebe52b07353e35ecb012c38735fcf9c.js:124:6959)
  at dispatchEvent(/assets/application-eebe52b07353e35ecb012c38735fcf9c.js:139:27375)
  at HTMLAudioElement.r(/assets/application-eebe52b07353e35ecb012c38735fcf9c.js:3:9163)
Reproduction Attempt

I spun up a VM of Windows 7 with the same versions of IE and Opera above, and ran our fiddles and attempted to reproduce to no avail. If someone wants to give this a shot on their own, you can download Opera here and a copy of Windows 7 with IE 11 here. Hopefully this new information will lead someone else to a reproduction. If anyone is keeping track of bugs and is seeing a similar browser pattern that may be useful to learn.

vinnymac avatar Jun 29 '16 15:06 vinnymac

Hi Folks,

I ran into this error too. I am using the html-webpack-plugin. I had a call for my js file in an index.template.html file I defined for the template property. Because the html webpack plugin injects the JavaScript bundle, my js file was being called twice. You can pass inject: false to the plugin's configuration object to prevent this behavior, or remove the <script> call in your template file. This will solve the error resulting from the getClosestInstanceFromNode function (if it stems from the plugin).

    plugins: [
        new webpack.optimize.OccurenceOrderPlugin(), // https://github.com/webpack/docs/wiki/optimization
        new webpack.HotModuleReplacementPlugin(),
        new webpack.NoErrorsPlugin(),
        new HtmlWebpackPlugin({
            template: 'index.template.html',
            inject: false,
            minify: {
                collapseWhitespace: true
            }
        })
    ]

Below are some screenshots to clarify.

Note the explicit <script> tag in my index.template.html file. ice_screenshot_20160902-135916

Note that I am accepting the default inject: true behavior of the html webpack plugin. ice_screenshot_20160902-135844

Note the two <script> calls. ice_screenshot_20160902-135801

johndugan avatar Sep 02 '16 23:09 johndugan

React: 15.3.2 Browsers: Google Chrome 56.0.2913.3 and FireFox 52.0a1 (2016-11-02) (64-bit)

  1. Cause an uncaught exception inside of mapStateToProps. In a lot of scenarios, this is never printed to the console. I don't have a repro on this bug. So you think everything is working.
  2. If this happens, you can easily reproduce this bug with an image load or any other tag that produces an event.

Since I'm using babel browser you see the exception, but in a lot of cases you don't see it. https://jsfiddle.net/joshunger/pqtvx3dz/1/

joshunger avatar Nov 10 '16 14:11 joshunger

React:15.3.0 , webpack:1.13.1 I am fairly new to react, working on a common dialog modal, where request(ajax) response needs to be displayed, Created a component dialog-modal(used bootstrap modal) image

image

and I was able to get the error image

All of this happened because I was removing the modal when onHide line number 8 in dialog-modal component, on changing that to just hide the error was gone. :) Before actually committing the transaction I deleted the node from DOM. Hope this helps some one.

nikhilgoud avatar Nov 11 '16 14:11 nikhilgoud

I got the same error due to exactly the reason @johndugan brought up.

osbertngok avatar Jan 02 '17 10:01 osbertngok

This happened to me because I had an unhandled exception in the render method of a component. The error only happened in Google Console's Fetch as Google. I didn't have the appropriate polyfill for the Googlebot agent to run my code properly. In this particular case, the offending line called Array.prototype.find . Changing myArray.find(myCondition) to myArray.filter(myCondition)[0] solved the problem.

sdeleon28 avatar Feb 05 '17 01:02 sdeleon28

The following would result in the Uncaught TypeError: Cannot read property '__reactInternalInstance$gf9gtshwv1avu0220061ug14i' of null whenever page navigating.

  render(
    <Provider store={store}>
      <App>
        <Layout user={window.env.user}>
          {components}
        </Layout>
      </App>
    </Provider>,
    document.getElementById('client')
  )

the remedy was to wrap things in one more element, new root level <div />.

  render(
    <div>
      <Provider store={store}>
        <App>
          <Layout user={window.env.user}>
            {components}
          </Layout>
        </App>
      </Provider>
    </div>,
    document.getElementById('client')
  )

thomas-siimpl avatar Feb 08 '17 18:02 thomas-siimpl

We are using React 15.4.0 and ReactDOM 15.4.0 with TypeScript , Webpack Then we are transpiling to ES5 for IE11 support.

In Chrome, Edge our app works fine. But getting error in IE11

SCRIPT5007: Unable to get property '@@__symbol:iterator0.57059978612322841' of undefined or null reference
polyfill.min.js (7,19646)

SCRIPT5007: Unable to get property '__reactInternalInstance$5hya2doizuj5' of undefined or null reference
react-dom.min.js (13,23434)

destromas1 avatar Feb 24 '17 09:02 destromas1

BTW , it was fixed after changing Polyfill CDN to babel-polyfill with Webpack Entry

destromas1 avatar Feb 24 '17 14:02 destromas1

I had a similar issue. It was resolved as soon as I closed the Firebug window. I couldn't get to the root cause, but at least this might help others as well. Took me 2 hours to find out..

typify avatar Mar 13 '17 09:03 typify

I can confirm @joshunger's observation that this happens when there is an uncaught exception in mapStateToProps. I see the same thing with React 15.4.2 and Chrome 57.0.2987.110 (64-bit), i.e. the console shows this trace three times in a row:

ReactDOMComponentTree.js:113 Uncaught TypeError: Cannot read property '__reactInternalInstance$x760fmy243' of null
    at Object.getClosestInstanceFromNode (ReactDOMComponentTree.js:113)
    at findParent (ReactEventListener.js:38)
    at handleTopLevelImpl (ReactEventListener.js:67)
    at ReactDefaultBatchingStrategyTransaction.perform (Transaction.js:140)
    at Object.batchedUpdates (ReactDefaultBatchingStrategy.js:62)
    at Object.batchedUpdates (ReactUpdates.js:97)
    at dispatchEvent (ReactEventListener.js:147)

Luckily it did then display the error caused by the bug in mapStateToProps, so I was able to locate the bug and fix it.

aspiers avatar Mar 26 '17 10:03 aspiers

I got this error too, but dont know why this happen. This is my code

import React from 'react';
import Logo from '../styles/images/logo.svg';
import '../styles/styles.scss';

const App = props => (
  <div className="wrapper">
    <div className="logo">
      <img src={Logo} alt="logo" />
      <p>Beleaf</p>
    </div>
  </div>
);

export default App;
ReactDOMComponentTree.js:113 Uncaught TypeError: Cannot read property '__reactInternalInstance$x760fmy243' of null
    at Object.getClosestInstanceFromNode (ReactDOMComponentTree.js:113)
    at findParent (ReactEventListener.js:38)
    at handleTopLevelImpl (ReactEventListener.js:67)
    at ReactDefaultBatchingStrategyTransaction.perform (Transaction.js:140)
    at Object.batchedUpdates (ReactDefaultBatchingStrategy.js:62)
    at Object.batchedUpdates (ReactUpdates.js:97)
    at dispatchEvent (ReactEventListener.js:147)

React version

"react": "^15.4.2",

If I removed image everything ok. Anyone know what happen here?

lyhoanglong avatar Apr 04 '17 02:04 lyhoanglong

@lyhoanglong Why dont you use image directly inside src="../styles/images/logo.svg" something like this ?

destromas1 avatar Apr 04 '17 08:04 destromas1

@destromas1 because sometime I can reuse this image. What's wrong if I use image this way?

lyhoanglong avatar Apr 04 '17 09:04 lyhoanglong

@lyhoanglong did you resolve your issue? I'm getting the same exact error as you and it appears every time I try to render an image

ugene1213 avatar Apr 19 '17 20:04 ugene1213

@ugene1213 I didnt and dont know how to fix this.

lyhoanglong avatar Apr 20 '17 13:04 lyhoanglong