简体   繁体   中英

how to re-render child component on state change(Parent) reactjs

I have an array list
logged in the child component which returns me the initial array.
After changing data from the API componentDidMount
I get an array of objects
if i log that array in the Parent component in the render function.
it is changing
but the child component it is not.
what shall i do ??

I have an array list
logged in the child component which returns me the initial array.
After changing data from the API componentDidMount
I get an array of objects
if i log that array in the Parent component in the render function.
it is changing
but the child component it is not.
what shall i do ??

I have an array list
logged in the child component which returns me the initial array.
After changing data from the API componentDidMount
I get an array of objects
if i log that array in the Parent component in the render function.
it is changing
but the child component it is not.
what shall i do ??

I have an array list
logged in the child component which returns me the initial array.
After changing data from the API componentDidMount
I get an array of objects
if i log that array in the Parent component in the render function.
it is changing
but the child component it is not.
what shall i do ??

I have an array list
logged in the child component which returns me the initial array.
After changing data from the API componentDidMount
I get an array of objects
if i log that array in the Parent component in the render function.
it is changing
but the child component it is not.
what shall i do ??

I have an array list
logged in the child component which returns me the initial array.
After changing data from the API componentDidMount
I get an array of objects
if i log that array in the Parent component in the render function.
it is changing
but the child component it is not.
what shall i do ??

You can use useState

eg

export function myChildComponent({myValue}) {
   const [MyValue, setMyValue] = useState(null);
   useEffect(() => {
       setMyValue(myValue);
   }, [myValue])
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM