From 6dad6d2b7a32bb03ee50e0bc783d9b364ab8de96 Mon Sep 17 00:00:00 2001 From: sw-yx Date: Sun, 8 Oct 2017 14:34:03 -0400 Subject: [PATCH 1/4] 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 e1ea2d3c..38b985ee 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 + +``` From 037fdf82d02532d59e08ec40c85d7a813d91524a Mon Sep 17 00:00:00 2001 From: sw-yx Date: Mon, 9 Oct 2017 22:11:11 -0400 Subject: [PATCH 2/4] modified handling-events page --- content/docs/handling-events.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/content/docs/handling-events.md b/content/docs/handling-events.md index 38b985ee..5a64a395 100644 --- a/content/docs/handling-events.md +++ b/content/docs/handling-events.md @@ -145,11 +145,5 @@ The problem with this syntax is that a different callback is created each time t 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 - -``` + +``` \ No newline at end of file From 3dfc414701a155a11694b212423265cc85fa3f5b Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Tue, 10 Oct 2017 08:32:29 -0700 Subject: [PATCH 3/4] Nit --- content/docs/handling-events.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/docs/handling-events.md b/content/docs/handling-events.md index 5a64a395..81da691c 100644 --- a/content/docs/handling-events.md +++ b/content/docs/handling-events.md @@ -145,5 +145,6 @@ The problem with this syntax is that a different callback is created each time t 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 + -``` \ No newline at end of file +``` From 7f8d084a2c35c519f010634c757c0bd1b2fb1d51 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Tue, 10 Oct 2017 08:33:00 -0700 Subject: [PATCH 4/4] Wordsmithing --- content/docs/handling-events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/handling-events.md b/content/docs/handling-events.md index 81da691c..4690d8c7 100644 --- a/content/docs/handling-events.md +++ b/content/docs/handling-events.md @@ -142,7 +142,7 @@ The problem with this syntax is that a different callback is created each time t ## 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: +Inside a loop it is common to want to pass a param to an event handler. For example, if `i` is the row id, either of the following would work: ```js