how to call a function in react with arguments onclick 1

how to call a function in react with arguments onclick

Here is what the above code is Doing:
1. We’re creating a function called sayHello.
2. We’re passing in a parameter called name.
3. We’re returning a string that says “Hello, ” and then the name that we passed in.
4. We’re creating a button that calls the sayHello function and passes in the name “James”.
5. When we click the button, we’ll see an alert that says “Hello, James”.

Similar Posts