We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I've a component whose render method looks like
render
render() { const {condition} = this.state; if (!condition) { return null; } return <div onClick={() => { doSomething(); }} > ... </div> }
When the state changes and condition changes from true to false, this triggers the error
condition
true
false
EventListener.js:37 Uncaught TypeError: Cannot read property 'addEventListener' of null Here is the trace if that helps:
EventListener.js:37 Uncaught TypeError: Cannot read property 'addEventListener' of null
EventListener.listen @ EventListener.js:37 SimpleEventPlugin.didPutListener @ SimpleEventPlugin.js:612 EventPluginHub.putListener @ EventPluginHub.js:113 putListener @ ReactDOMComponent.js:175 _assign.notifyAll @ CallbackQueue.js:66 ON_DOM_READY_QUEUEING.close @ ReactReconcileTransaction.js:79 Mixin.closeAll @ Transaction.js:202 Mixin.perform @ Transaction.js:149 Mixin.perform @ Transaction.js:136 _assign.perform @ ReactUpdates.js:89 flushBatchedUpdates @ ReactUpdates.js:165 ReactUpdates_flushBatchedUpdates @ ReactPerf.js:66 Mixin.closeAll @ Transaction.js:202 Mixin.perform @ Transaction.js:149 ReactDefaultBatchingStrategy.batchedUpdates @ ReactDefaultBatchingStrategy.js:63 batchedUpdates @ ReactUpdates.js:97 ReactEventListener.dispatchEvent @ ReactEventListener.js:150
Returning an empty div instead of null fixes the issue:
render() { const {condition} = this.state; if (!condition) { return <div></div>; } return <div onClick={() => { doSomething(); }} > ... </div> }
The text was updated successfully, but these errors were encountered:
@gsabran can you a share a JSFiddle reproducing the error?
Sorry, something went wrong.
Probably a duplicate of #6538
Sounds like a duplicate. Sorry about that. I could not get a simple JSFiddle to reproduce... Feel free to close it.
No branches or pull requests
I've a component whose
render
method looks likeWhen the state changes and
condition
changes fromtrue
tofalse
, this triggers the errorEventListener.js:37 Uncaught TypeError: Cannot read property 'addEventListener' of null
Here is the trace if that helps:
Returning an empty div instead of null fixes the issue:
The text was updated successfully, but these errors were encountered: