what I want to do is: the three components of react-redux are used to manage data, but the problem I encounter now is: B through attribute assignment, c receives the value of a through props, but the state value of b changes, but c will not change. It"s strange
handleSearch(value) {
this.state.historyList.push(value)
this.setState({
historyList: this.state.historyList //1
})
}
render() {
return (
<Fragment>
<SearchHeader toSubmit={this.handleSearch}/>
<SearchContent historyList={this.state.historyList} /> //2
</Fragment>
)
}
as shown in the code: originally this.state.historyList
can be used to pass values to child components SearchContent
through attributes. To achieve the state change of the intermediate component state, the render function of the subcomponent is called to refresh the data again.
but I found: export default connect (mapStateToProps, mapDispatchToProps) (SearchContent)
connects the subcomponent with connect, and
finally the this.state.historyList
of the intermediate component changes, and the subcomponent does not trigger the call of the render function.
but change to export default SearchContent
so that you can receive new data
where is it wrong?