Answer the question
In order to leave comments, you need to log in
How to display new data that came through props?
There is a component that receives data from the store and puts it in props
function Details(props: any) {
let details: any
const routeParams: any = useParams();
useEffect(() => {
details = props.victims.find((victim: any) => routeParams.pk == victim.pk)
console.log(details)
}, [props.victims])
return(
<>
{
details && Object.keys(details.fields).map((f: string, i: number) => f)
}
</>
)
}
const mapStateToProps = (state: appStateType) => {
return {
victims: state.victimsReducer.victims,
}
}
export default connect(mapStateToProps, {})(Details);
useEffect
works after return
. But the data that I need to display is formed in useEffect
. Therefore, the browser displays a blank screen (although the console shows that there is data). details.fields
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