-
Notifications
You must be signed in to change notification settings - Fork 46.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React 15 update: Uncaught TypeError: Cannot read property 'addEventListener' of null #6538
Comments
Curious: What browser+version are you using when you see this error? Any chance it's Chrome 49? Can you reproduce on Firefox or any other browser? |
Also, can you provide a simple jsfiddle that demonstrates the issue? |
@jimfb It also reproduces on firefox developer version 47.0a2 (2016-04-18) It is a big application we have. I will try to create a small fiddle for reproducing. |
+1, I also saw this annoying message output every time after adopting React v15. I found that typeError can be removed by deleting onClick event in div and is able to reproduce every time. <div ... onClick={ onClick }></div> to <div ... ></div> It happened on Chrome 49.0 and Firefox 48 (it threw TypeError: target is null) and Safar 9.1i. |
@rickychien @omerts If someone could try to produce a minimal repro / jsfiddle, that would be very helpful! |
@rickychien @omerts Another question, are you guys using ReactRouter and/or Redux? |
We're seeing the same issue and are using both ReactRouter and Redux.
We see this even if we switch back to React 0.14.8, so I don't think it is specific to React 15. We can only reproduce the issue by switching pages via Weirdly, our application has tons of other buttons with |
Posted a Codepen over in #6371 |
We are having this issue as well, both with We started having this issue once we added a Our core dependencies are:
|
I trimmed it down to a case that involves just React. Fiddle: https://jsfiddle.net/ycLw3bbq/ var callbacks = [];
function emitChange() {
callbacks.forEach(c => c());
}
class App extends React.Component {
constructor(props) {
super(props);
this.state = { showChild: true };
}
componentDidMount() {
this.setState({ showChild: false });
}
render() {
return (
<div>
<ForceUpdatesOnChange />
{this.state.showChild && <EmitsChangeOnUnmount />}
</div>
);
}
}
class EmitsChangeOnUnmount extends React.Component {
componentWillUnmount() {
emitChange();
}
render() {
return null;
}
}
class ForceUpdatesOnChange extends React.Component {
componentDidMount() {
this.onChange = () => this.forceUpdate();
this.onChange()
callbacks.push(this.onChange);
}
componentWillUnmount() {
callbacks = callbacks.filter(c => c !== this.onChange)
}
render() {
return (
<div key={Math.random()} onClick={function(){}} />
)
}
}
ReactDOM.render(<App />, document.getElementById('container')); |
Also, a few observations:
|
Replacing render() {
return (
<div key={Math.random()} onClick={function(){}} />
)
} with render() {
return (
<img key={Math.random()} />
)
} reproduces #6371 ( |
I guess the issue here is that all I think the sequence is:
|
Yet another manifestation of the same issue (this time, only in master). render() {
return (
<input key={Math.random()} />
)
} gives |
I won’t be looking into this more for now as I’m not sure how to proceed. This is a visualization of what happens. |
+1 I have the same error since i upgraded to 15 |
Fixes facebook#2410. Fixes facebook#6371. Fixes facebook#6538. I also manually tested the codepen in facebook#3762 and verified it now works.
Fixes facebook#2410. Fixes facebook#6371. Fixes facebook#6538. I also manually tested the codepen in facebook#3762 and verified it now works.
Just upgraded from 0.14.7 to 15.0.2 to get the fix for #3762. I'm rendering to I will see if I can create a test case, but wanted to note it here for the record, since it seems like the bugs are related. |
I just landed a fix for this (#6650) which will be in 15.0.3 or 15.1.0, whichever we release next. |
This may be useful: broken <figure className='clip-card' onClick={::this.onClick}> broken <figure className='clip-card' onClick={() => this.onClick()}> doesn't throw but obviously doesn't do what I want :) <figure className='clip-card' onClick={this.onClick}> In my case I was using I was on Chrome |
No need for additional repro cases now unless you confirm they're still broken in master (or in 15.0.3/15.1.0 when they come out). |
@spicyj I'll give it a go, is it |
@kilianc master branch. |
Easiest is to install from npm from http://react.zpao.com/builds/master/latest/react.tgz because you can't use our github repo without building. |
I can't reproduce anymore with both 15.0.2 and master. It must have been a race condition that doesn't happen anymore :( |
@kilianc I believe this issue is fixed in master. Not sure why you're unable to repro on 15.0.2. There was also a super similar issue that was only showing up on chrome 49, which vanishes when you upgrade to chrome 50. Chrome browsers auto-update at some point, so perhaps that was your issue. Either way, glad it's resolved for you! |
@jimfb indeed, I have never had this issue again |
I also had this issue, using Chrome 50 and React 15.0.2, and it was not easy to track down. Like @rickychien, I could resolve it temporarily by removing the |
@Schneck It will be solved with the next update. |
rowClick(e){
{this.state.items.map(function(item, key){
am, not able to call function in table its giving error |
Hey, @Rajesh-Hegde! This issue is closed, but I thought I'd take a quick stab. Checking the following line:
When using
Beyond that, it this doesn't appear to be an issue with React itself. We try to keep this issue board focused on issues with the React library itself. Checkout the https://www.reactiflux.com/ chat community, where you might be able to get more rapid turn on troubleshooting. Good luck! |
Hello,
After updating to React 15.0.1, we are getting the following error:
The text was updated successfully, but these errors were encountered: