This is a place where it is ok to fork props and state.
class Counter {
constructor(props) {
super(props);
this.state = {
count: props.count;
};
}
}
This is not an invitation to begin a synchronization dance between state and props.
Setting state here will not trigger a render
class Counter extends Component {
componentWillMount() {
this.setState({
count: props.count
});
}
}
This is primarily for server side rendering. I don't think there is any reason for us to use this method.
class Counter extends React.Component {
componentDidMount() {
this.textInput.focusTextInput();
this.props.fetchInitialCount();
}
render() {
return (
<SimpleTextInput
ref={(input) => { this.textInput = input; }} />
);
}
}
Text