How can I create shared state for HOC?
问题 I have created LoadBookHOC which is wrapped with BookDetails and BookSummary component. LoadBookHOC.js const LoadBookHOC = InnerComponent => class LoadBook extends React.Component { constructor(){ super(); this.state={ book: [] }; } set= obj => this.setState(obj); render(){ return( <InnerComponent {...this.props} hocState={this.state} hocSetState={this.set} /> ); } } BookDetails.js this.hocSetState({book: <new data>}); BookSummary.js this.hocSetState({book: <new data>}); Whenever this.props