change a parent’s state using child arrow functions react

In parent:

const youNameOfCallback = (array) => {
  setTessState(array)
}

<ChildComponent youNameOfCallback={youNameOfCallback} />

In child:

useEffect(() => {
  props.youNameOfCallback(YouArrayFromChild)
}, [])

This will be apply when child will be mounted.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top