Challenge Solution
Challenge Solution
Learning Objective
Create a basic React component and use it in the JSX code of another
component.
Solution
Learning Objective
onClick={handleClick}
You defined the handleClick function and then passed it as a
prop to <button>. handleClick is an event handler.
Event handler functions:
a. Are usually defined inside your components.
b. Have names that start with handle, followed by the name of
the event.
Functions passed to event handlers must be passed, not
called.
Note:
You can use the {() => handleClick()} approach when you need to
pass arguments to the event handler or when you need to
perform some additional logic before calling the handler.
Output:
Challenge 03
Learning Objective
Next, we use the map function to iterate over the chairs array
which can helps us go through each chair in the list.