From 6dad6d2b7a32bb03ee50e0bc783d9b364ab8de96 Mon Sep 17 00:00:00 2001 From: sw-yx Date: Sun, 8 Oct 2017 14:34:03 -0400 Subject: [PATCH] added documentation for passing arguments to event handlers --- content/docs/handling-events.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/content/docs/handling-events.md b/content/docs/handling-events.md index e1ea2d3cf..38b985ee7 100644 --- a/content/docs/handling-events.md +++ b/content/docs/handling-events.md @@ -139,3 +139,17 @@ class LoggingButton extends React.Component { ``` The problem with this syntax is that a different callback is created each time the `LoggingButton` renders. In most cases, this is fine. However, if this callback is passed as a prop to lower components, those components might do an extra re-rendering. We generally recommend binding in the constructor or using the class fields syntax, to avoid this sort of performance problem. + +## Passing arguments to event handlers + +Inside a loop it is common to want to pass a param to an event handler. For example if `i` is the row id: + +```js + +``` + +or alternatively (especially if you want to avoid triggering a re-render in a child component): + +```js + +```