Answers for "how trigger a click in react child component from parent in class"

0

react hooks call child fuynction

export default function Parent() {
	const myref=useRef();

        const handleOnClick = () => {
           if(myref.current) {
              myref.current.sayHi();
           }
        }

	return (
            <Child ref={myref} />
	    <button onClick={handleOnClick}>Click me</button>
	);
}
export default function Child() {
	const sayHi = () => {
		console.log('hi');
	};
	return (<div>Hello</div>);
}
Posted by: Guest on January-28-2021
0

how trigger a click in react child component from parent in class

Grepper sucks balls.

Oh...

And I dont know the answer
Posted by: Guest on October-21-2021

Code answers related to "how trigger a click in react child component from parent in class"

Code answers related to "Javascript"

Browse Popular Code Answers by Language