Skip to content

Commit

Permalink
Merge pull request #8 from yangshun/constructor-props
Browse files Browse the repository at this point in the history
Ensure all class constructors call super with props
  • Loading branch information
bvaughn authored Oct 7, 2017
2 parents 6c19b64 + 7c6f185 commit 463640d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions content/blog/2015-01-27-react-v0.13.0-beta-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions content/docs/higher-order-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 16 additions & 16 deletions content/tutorial/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -228,8 +228,8 @@ Now the `<button>` tag looks like this:
```javascript{10-12}
class Square extends React.Component {
constructor() {
super();
constructor(props) {
super(props);
this.state = {
value: null,
};
Expand Down Expand Up @@ -282,8 +282,8 @@ Pulling state upwards like this is common when refactoring React components, so
```javascript{2-7}
class Board extends React.Component {
constructor() {
super();
constructor(props) {
super(props);
this.state = {
squares: Array(9).fill(null),
};
Expand Down Expand Up @@ -399,8 +399,8 @@ Try clicking a square – you should get an error because we haven't defined `ha
```javascript{9-13}
class Board extends React.Component {
constructor() {
super();
constructor(props) {
super(props);
this.state = {
squares: Array(9).fill(null),
};
Expand Down Expand Up @@ -528,8 +528,8 @@ Let's default the first move to be by 'X'. Modify our starting state in our Boar
```javascript{6}
class Board extends React.Component {
constructor() {
super();
constructor(props) {
super(props);
this.state = {
squares: Array(9).fill(null),
xIsNext: true,
Expand Down Expand Up @@ -564,8 +564,8 @@ After these changes you should have this Board component:
```javascript{6,11-16,29}
class Board extends React.Component {
constructor() {
super();
constructor(props) {
super(props);
this.state = {
squares: Array(9).fill(null),
xIsNext: true,
Expand Down Expand Up @@ -715,8 +715,8 @@ First, set up the initial state for Game by adding a constructor to it:
```javascript{2-10}
class Game extends React.Component {
constructor() {
super();
constructor(props) {
super(props);
this.state = {
history: [{
squares: Array(9).fill(null),
Expand Down Expand Up @@ -1006,8 +1006,8 @@ First, add `stepNumber: 0` to the initial state in Game's `constructor`:

```js{8}
class Game extends React.Component {
constructor() {
super();
constructor(props) {
super(props);
this.state = {
history: [{
squares: Array(9).fill(null),
Expand Down

0 comments on commit 463640d

Please sign in to comment.