I don't understand why my state isn't updating in this code. I reviewed an answer here but doesn't seem to answer my question b/c I only have one component to bind to.
import React from 'react';
import ReactDOM from 'react-dom';
class App extends React.Component {
constructor() {
super();
this.state={
headline: 'this is headline state',
cat: 25
}
}
update(e) {
this.setState=({headline: e.target.value})
}
render() {
let headline=this.state.headline
return (
<div>
<input type="text"
onChange={this.update.bind(this)} />
<h1>{headline}</h1>
</div>
);
}
}
App.propTypes = {
headline: React.PropTypes.string,
cat: React.PropTypes.number
}
ReactDOM.render(
<App />,
document.getElementById('app')
);
componentWillMount() { this.setState( { your initial state }) }