From f57b73da2b0879ad4f4fec49976e9f3b3bd7fe0f Mon Sep 17 00:00:00 2001 From: Billy Janitsch Date: Thu, 22 Mar 2018 21:08:25 -0400 Subject: [PATCH] Clarify render prop caveat --- content/docs/render-props.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/content/docs/render-props.md b/content/docs/render-props.md index 6c473f12..9b0ec9fa 100644 --- a/content/docs/render-props.md +++ b/content/docs/render-props.md @@ -305,14 +305,8 @@ To get around this problem, you can sometimes define the prop as an instance met ```js class MouseTracker extends React.Component { - constructor(props) { - super(props); - - // This binding ensures that `this.renderTheCat` always refers - // to the *same* function when we use it in render. - this.renderTheCat = this.renderTheCat.bind(this); - } - + // Defined as an instance method, `this.renderTheCat` always + // refers to *same* function when we use it in render renderTheCat(mouse) { return ; } @@ -328,4 +322,4 @@ class MouseTracker extends React.Component { } ``` -In cases where you cannot bind the instance method ahead of time in the constructor (e.g. because you need to close over the component's props and/or state) `` should extend `React.Component` instead. +In cases where you cannot define the prop statically (e.g. because you need to close over the component's props and/or state) `` should extend `React.Component` instead.