Warn when reading from event which has been returned to the pool
See original GitHub issueThe title is an assumption based on my experience upgrading. Here’s an example of what I’m seeing:
const App = React.createClass({
getInitialState() {
return {clicked: 0}
},
handleClick(e) {
console.log('e.target before callback is null?', e.target === null) // e.target is not null here
this.setState({
clicked: this.state.clicked + 1
}, () => {
console.log('e.target after callback is null?', e.target === null) // e.target is null here
})
},
render() {
return (
<div
onClick={this.handleClick}
>
Click me {this.state.clicked}
</div>
)
}
})
ReactDOM.render(<App />, document.getElementById('root'))
Here’s a jsbin that demonstrates the behavior with 0.14.6
: https://jsbin.com/gasozit/edit?js,console,output
Here’s a jsbin with 0.14.7
: https://jsbin.com/vaberi/edit?js,console,output
Notice in the console, that the log inside the callback is logging that e.target === null
evaluates to true
. In my app, I’m passing the event
to an onChange
handler which utilizes the target
. So this update breaks that situation.
This may or may not be a bug. It may just be necessary for avoiding the memory leak. If that’s the case, then it’s a support request 😄 How should I handle this if I’m passing the event
to another callback and I want that event to have references to things like target
?
Issue Analytics
- State:
- Created 8 years ago
- Comments:13 (13 by maintainers)
I didn’t know
persist()
existed! This made my day.I’d love to make this my first contribution if you don’t mind holding off for a bit for me to work on it. 😄