Skip to content

Commit f57b73d

Browse files
committed
Clarify render prop caveat
1 parent 2793656 commit f57b73d

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

content/docs/render-props.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,8 @@ To get around this problem, you can sometimes define the prop as an instance met
305305

306306
```js
307307
class MouseTracker extends React.Component {
308-
constructor(props) {
309-
super(props);
310-
311-
// This binding ensures that `this.renderTheCat` always refers
312-
// to the *same* function when we use it in render.
313-
this.renderTheCat = this.renderTheCat.bind(this);
314-
}
315-
308+
// Defined as an instance method, `this.renderTheCat` always
309+
// refers to *same* function when we use it in render
316310
renderTheCat(mouse) {
317311
return <Cat mouse={mouse} />;
318312
}
@@ -328,4 +322,4 @@ class MouseTracker extends React.Component {
328322
}
329323
```
330324

331-
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) `<Mouse>` should extend `React.Component` instead.
325+
In cases where you cannot define the prop statically (e.g. because you need to close over the component's props and/or state) `<Mouse>` should extend `React.Component` instead.

0 commit comments

Comments
 (0)