Skip to content

Commit

Permalink
Document interaction between native and React events
Browse files Browse the repository at this point in the history
Closes: reactjs#68
  • Loading branch information
srittau committed Oct 28, 2017
1 parent ff8ef81 commit 32a9908
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions content/docs/handling-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ Here, `e` is a synthetic event. React defines these synthetic events according t

When using React you should generally not need to call `addEventListener` to add listeners to a DOM element after it is created. Instead, just provide a listener when the element is initially rendered.

> Note:
>
> For performance reasons, React events are not guaranteed to be installed on the element they are created on. This means that using `stopPropagation` from event handlers installed outside of React might not be able to stop React events from occurring and vice versa.
When you define a component using an [ES6 class](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes), a common pattern is for an event handler to be a method on the class. For example, this `Toggle` component renders a button that lets the user toggle between "ON" and "OFF" states:

```js{6,7,10-14,18}
Expand Down
4 changes: 4 additions & 0 deletions content/docs/reference-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ string type
>
> As of v0.14, returning `false` from an event handler will no longer stop event propagation. Instead, `e.stopPropagation()` or `e.preventDefault()` should be triggered manually, as appropriate.
> Note:
>
> Do not try to stop the execution of React events from native event handlers using `e.stopPropagation()` or vice versa. React events are not necessarily installed on the DOM element they are created on.
### Event Pooling

The `SyntheticEvent` is pooled. This means that the `SyntheticEvent` object will be reused and all properties will be nullified after the event callback has been invoked.
Expand Down

0 comments on commit 32a9908

Please sign in to comment.