Answers for "trigger function in child react"

3

trigger function in child react

// Alternative method with useEffect:

// Parent:
const [refresh, doRefresh] = useState(0);
<Button onClick={() => doRefresh(prev => prev + 1)} />
<Children refresh={refresh} />

// Children:
useEffect(() => {
  performRefresh();
}, [props.refresh]);
Posted by: Guest on February-25-2022

Code answers related to "trigger function in child react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language