learn-co-curriculum/react-hooks-event-handling-lab(新しいタブで開きます)
主要言語: JavaScript
- star 数
- 6
- watcher 数
- 13
- fork 数
- 6,426
- issue 数
- 17
- 最終更新
- 2024/06/11
主要言語: JavaScript
In this lab, you'll respond to events in React and write event handlers.
Note: The components are not defined yet, but the files are present. Before the tests will run, you must export components from
EyesOnMe.jsandKeypad.js. To get started, write very basic components that you know will not pass all the tests, but at least be valid React.
Mr. Burns has requested us to build a new keypad component for the nuclear
plant, since the last one was way too complicated for his employees to use.
We'll keep things super simple instead, and use an <input type="password" />
field to capture input. Here's how to complete the exercise:
components/Keypad.js file, create a Keypad React component.input with the right type.input, add an event handler that listens for the change event.console.log to print out the text 'Entering password...'.Let's say you're in the club with your buddy. The music's blaring, lights are flashing... It's so hard to get his attention! Your job is to create a component that registers whenever he focuses on you, and when his eyes are drifting off.
components/EyesOnMe.js file, create a EyesOnMe React component.button with the text 'Eyes on me'.button, add event handlers that listen for the focus and blur events.focus event fires, use console.log to print out the text 'Good!'.blur event fires, use console.log to print out the text 'Hey! Eyes on me!'.