Skip to content

Commit 32a71b5

Browse files
Fix prop-types
1 parent ae8fb73 commit 32a71b5

7 files changed

+27
-14
lines changed

instructions/1-your-first-component.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ export class MyComponent extends Component {
162162
You can provide some validation for the `props` of a component using `React.PropTypes` to have error message in developement. it's quite useful when you provide components to other dev teams.
163163

164164
```javascript
165-
import React, { Component, PropTypes } from 'react';
165+
import React, { Component } from 'react';
166+
import PropTypes from 'prop-types';
166167

167168
export class MyComponent extends Component {
168169

@@ -290,7 +291,8 @@ Let's write a nice component that will display details of a wine. This wine will
290291
First let's just display it's name
291292

292293
```javascript
293-
import React, { Component, PropTypes } from 'react';
294+
import React, { Component } from 'react';
295+
import PropTypes from 'prop-types';
294296

295297
export class Wine extends Component {
296298

@@ -399,7 +401,8 @@ Let say the `<Wine />` component should now look like
399401
to achieve that, you will create a new component called `<LikeButton />` with the following contract
400402

401403
```javascript
402-
import React, { Component, PropTypes } from 'react';
404+
import React, { Component } from 'react';
405+
import PropTypes from 'prop-types';
403406

404407
export class LikeButton extends Component {
405408

instructions/2-the-wine-app.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ Create all *Dumb Components*: `<Regions />`, `<WineList />` and `<Wine />` and i
8383
The `<Regions />` component just display a list of regions. The contract of the `<Regions />` component is the following
8484

8585
```javascript
86-
import React, { Component, PropTypes } from 'react';
86+
import React, { Component } from 'react';
87+
import PropTypes from 'prop-types';
8788

8889
export class Regions extends Component {
8990
static propTypes = {
@@ -142,7 +143,8 @@ the view of `<WineList />` component will look something like
142143
The `<Wine />` component display a list of wine for the selected region. The contract of the `<Wine />` component is the following
143144

144145
```javascript
145-
import React, { Component, PropTypes } from 'react';
146+
import React, { Component } from 'react';
147+
import PropTypes from 'prop-types';
146148

147149
export class Wine extends Component {
148150

instructions/4-handle-likes.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export function isWineLiked(id) {
3737
Now, you have to write a new component to display the `like` button into a `<Wine />` component. The button will be added in the `card-action` section. This component will have the following contract
3838

3939
```javascript
40-
import React, { Component, PropTypes } from 'react';
40+
import React, { Component } from 'react';
41+
import PropTypes from 'prop-types';
4142

4243
export class LikeButton extends Component {
4344

@@ -71,7 +72,8 @@ when the wine is liked, the button must look something like the following snippe
7172
If you need to react to the change of a property value in a component, you can use the `componentWillReceiveProps` function
7273

7374
```javascript
74-
import React, { Component, PropTypes } from 'react';
75+
import React, { Component } from 'react';
76+
import PropTypes from 'prop-types';
7577

7678
export class LikeButton extends Component {
7779

instructions/5-handle-comments.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export function fetchComments(id) {
2323
The `<CommentList />` will be added in the `card-action` section and will have the following contract
2424

2525
```javascript
26-
import React, { Component, PropTypes } from 'react';
26+
import React, { Component } from 'react';
27+
import PropTypes from 'prop-types';
2728

2829
export class CommentList extends Component {
2930

@@ -57,7 +58,8 @@ We can see that the comment list will use another component to display each comm
5758
The `<Comment />` component will have the following contract
5859

5960
```javascript
60-
import React, { Component, PropTypes } from 'react';
61+
import React, { Component } from 'react';
62+
import PropTypes from 'prop-types';
6163

6264
export class Comment extends Component {
6365
static propTypes = {

instructions/6-integrate-with-third-party-apis.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ the comment button is a very simple component, its only job is to trigger the `<
3232
The contract of `<CommentButton />` is the following
3333

3434
```javascript
35-
import React, { Component, PropTypes } from 'react';
35+
import React, { Component } from 'react';
36+
import PropTypes from 'prop-types';
3637

3738
export class CommentButton extends Component {
3839
static propTypes = {
@@ -59,7 +60,8 @@ The only issue is that the [materialize css modal component](http://materializec
5960
The contract of `<CommentModal />` is the following
6061

6162
```javascript
62-
import React, { Component, PropTypes } from 'react';
63+
import React, { Component } from 'react';
64+
import PropTypes from 'prop-types';
6365

6466
export class CommentModal extends Component {
6567

@@ -121,7 +123,8 @@ to use this code inside a our React component, we need to get a reference to the
121123
To do that we are going to use React refs
122124

123125
```javascript
124-
import React, { Component, PropTypes } from 'react';
126+
import React, { Component } from 'react';
127+
import PropTypes from 'prop-types';
125128

126129
export class CommentModal extends Component {
127130
...

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"es-symbol": "1.1.2",
1010
"es6-shim": "0.35.3",
1111
"prettier": "1.7.4",
12+
"prop-types": "15.6.0",
1213
"react": "16.0.0",
1314
"react-dom": "16.0.0",
1415
"whatwg-fetch": "2.0.3"

yarn.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -5041,7 +5041,7 @@ preserve@^0.2.0:
50415041
version "0.2.0"
50425042
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
50435043

5044-
prettier@^1.7.4:
5044+
50455045
version "1.7.4"
50465046
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.7.4.tgz#5e8624ae9363c80f95ec644584ecdf55d74f93fa"
50475047

@@ -5091,7 +5091,7 @@ promise@^7.1.1:
50915091
dependencies:
50925092
asap "~2.0.3"
50935093

5094-
prop-types@^15.6.0:
5094+
prop-types@15.6.0, prop-types@^15.6.0:
50955095
version "15.6.0"
50965096
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856"
50975097
dependencies:

0 commit comments

Comments
 (0)