From 7c6f185134a15176345be3eea54482c1e2e46fbf Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Sat, 7 Oct 2017 00:57:51 +0800 Subject: [PATCH] Ensure all class constructors call super with props --- .../blog/2015-01-27-react-v0.13.0-beta-1.md | 4 +-- content/docs/higher-order-components.md | 4 +-- content/tutorial/tutorial.md | 32 +++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/content/blog/2015-01-27-react-v0.13.0-beta-1.md b/content/blog/2015-01-27-react-v0.13.0-beta-1.md index a2cd597e3d1..76fea92da4d 100644 --- a/content/blog/2015-01-27-react-v0.13.0-beta-1.md +++ b/content/blog/2015-01-27-react-v0.13.0-beta-1.md @@ -89,8 +89,8 @@ Therefore we decided not to have this built-in into React's class model. You can ```javascript class Counter extends React.Component { - constructor() { - super(); + constructor(props) { + super(props); this.tick = this.tick.bind(this); } tick() { diff --git a/content/docs/higher-order-components.md b/content/docs/higher-order-components.md index 573c6cd78cb..d5d2a77818d 100644 --- a/content/docs/higher-order-components.md +++ b/content/docs/higher-order-components.md @@ -30,8 +30,8 @@ For example, say you have a `CommentList` component that subscribes to an extern ```js class CommentList extends React.Component { - constructor() { - super(); + constructor(props) { + super(props); this.handleChange = this.handleChange.bind(this); this.state = { // "DataSource" is some global data source diff --git a/content/tutorial/tutorial.md b/content/tutorial/tutorial.md index 0e8ccfd9c63..b940c0c873e 100644 --- a/content/tutorial/tutorial.md +++ b/content/tutorial/tutorial.md @@ -200,8 +200,8 @@ First, add a constructor to the class to initialize the state: ```javascript{2-7} class Square extends React.Component { - constructor() { - super(); + constructor(props) { + super(props); this.state = { value: null, }; @@ -228,8 +228,8 @@ Now the `