You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Notice how the `App` component does not need to know *what*`Toolbar` will do with `onPlayMovie` or `onUploadImage`. That's an implementation detail of the `Toolbar`. Here, `Toolbar` passes them down as `onClick` handlers to its `Button`s, but it could later also trigger them on a keyboard shortcut. Naming props after app-specific interactions like `onPlayMovie` gives you the flexibility to change how they're used later.
328
-
329
-
<Note>
330
-
331
-
Make sure that you use the appropriate HTML tags for your event handlers. For example, to handle clicks, use [`<button onClick={handleClick}>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button) instead of `<div onClick={handleClick}>`. Using a real browser `<button>` enables built-in browser behaviors like keyboard navigation. If you don't like the default browser styling of a button and want to make it look more like a link or a different UI element, you can achieve it with CSS. [Learn more about writing accessible markup.](https://developer.mozilla.org/en-US/docs/Learn/Accessibility/HTML)
332
-
>>>>>>> abe931a8cb3aee3e8b15ef7e187214789164162a
333
325
334
326
</Note>
335
327
@@ -424,21 +416,12 @@ button { margin: 5px; }
424
416
425
417
当你点击按钮时:
426
418
427
-
<<<<<<< HEAD
428
419
1. React 调用了传递给 `<button>` 的 `onClick` 处理函数。
429
420
2. 定义在 `Button` 中的处理函数执行了如下操作:
430
421
* 调用 `e.stopPropagation()`,阻止事件进一步冒泡。
431
422
* 调用 `onClick` 函数,它是从 `Toolbar` 组件传递过来的 prop。
432
423
3. 在 `Toolbar` 组件中定义的函数,显示按钮对应的 alert。
433
424
4. 由于传播被阻止,父级 `<div>` 的 `onClick` 处理函数不会执行。
434
-
=======
435
-
1. React calls the `onClick` handler passed to `<button>`.
436
-
2. That handler, defined in `Button`, does the following:
437
-
* Calls `e.stopPropagation()`, preventing the event from bubbling further.
438
-
* Calls the `onClick` function, which is a prop passed from the `Toolbar` component.
439
-
3. That function, defined in the `Toolbar` component, displays the button's own alert.
440
-
4. Since the propagation was stopped, the parent `<div>`'s `onClick` handler does *not* run.
0 commit comments