React.js Recommended Assigning `props` Directly To State
问题 A React.js warning was thrown: IndexPage: It is not recommended to assign props directly to state because updates to props won't be reflected in state. In most cases, it is better to use props directly. I had the following code: class IndexPage extends React.Component<IProps, IState> { constructor(props) { super(props) this.state = props } } But, when I have changed my code to: class IndexPage extends React.Component<IProps, IState> { constructor(props) { super(props) this.state = {...props}