Skip to content

Commit 23a9f15

Browse files
committed
moar
1 parent 4fefb00 commit 23a9f15

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

beta/src/pages/learn/index.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,25 @@ export default function Profile() {
191191
192192
</Sandpack>
193193
194-
195194
Here, `style={{ }}` is not a special syntax, but a regular object inside the JSX curlies.
196195
196+
## Responding to events {/*responding-to-events*/}
197+
198+
You can respond to events by declaring event handler functions inside your components:
199+
200+
```js {2-4,7}
201+
function MyButton() {
202+
function handleClick() {
203+
alert('You clicked me!');
204+
}
205+
206+
return (
207+
<button onClick={handleClick}>
208+
Click me
209+
</button>
210+
);
211+
}
212+
```
213+
214+
Notice how `onClick={handleClick}` has no parentheses at the end. You don't need to _call_ your event handler, you need to _pass_ the event handler itself. React will call your handler when the user clicks the button.
215+

0 commit comments

Comments
 (0)