Answer the question
In order to leave comments, you need to log in
How to avoid looping when updating props?
I have a reducer that puts some array of values in state. There is a component that receives these values from the server and places them in state
function Victims(props) {
useEffect(() => {
apiRequest('/victims')
.then(res => {
store.dispatch(actionCreator(victims))
})
}, [props.victims]);
return(
<>
Victims comp
</>
)
}
const mapStateToProps = state => {
return {
victims: state.victimsReducer.victims,
}
}
export default connect(mapStateToProps, { })(Victims);
получение данных -> помещение их в state
[props.victims]
[props.victims]
. And so on ad infinitum Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question