Created
February 3, 2021 13:31
-
-
Save itaditya/22f3225dbf1d6fbc69c7e33f991ef946 to your computer and use it in GitHub Desktop.
sayHello is a function defined in Actor function component. Can you make App component call the sayHello function?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Actor({ name }) { | |
function sayHello() { | |
console.log('hello', name); | |
} | |
return ( | |
<button onClick={sayHello}> | |
Say Hello | |
</button> | |
); | |
} | |
export default function App() { | |
function handleClick() { | |
// call sayHello somehow. | |
} | |
return ( | |
<div className="app"> | |
<Actor name="Tom" /> | |
<Actor name="Peter" /> | |
<hr /> | |
<button onClick={handleClick}> | |
I'll make Tom say hello | |
</button> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment