score:3

Accepted answer

pass down a callback to the child.

const parent = () => {
  const [value, setvalue] = usestate('')

  return <child setvalue={setvalue}/>
}

...

const child = ({setvalue}) => {
  // use setvalue here which will update parent state
}

score:0

you can do many type of solution for this

  1. passing method wich that do setstate to child and call it in there then you can update the state of parent wich gets from props.

    const parent = () => { const [value, setvalue] = usestate('') return (); }

    const child = ({setvalue}) => {}

  2. do it with redux or another state management libraries .


Related Query

More Query from same tag