Skip to content

Commit c65dfa6

Browse files
committed
Add flow-react-proptypes
1 parent 158f3af commit c65dfa6

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

tutorial/04-webpack-react-hmr.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,19 @@ const App = () => <h1>Hello React!</h1>
199199
export default App
200200
```
201201

202-
Since we use the JSX syntax here, we have to tell Babel that it needs to transform it as well.
202+
Since we use the JSX syntax here, we have to tell Babel that it needs to transform it with the `babel-preset-react` preset. And while we're at it, we're also going to add a Babel plugin called `flow-react-proptypes` which automatically generates PropTypes from Flow annotations for your React components.
203203

204-
- Run `yarn add --dev babel-preset-react` and add `react` to your `.babelrc` file like so:
204+
- Run `yarn add --dev babel-preset-react babel-plugin-flow-react-proptypes` and edit your `.babelrc` file like so:
205205

206206
```json
207207
{
208208
"presets": [
209209
"env",
210210
"flow",
211211
"react"
212+
],
213+
"plugins": [
214+
"flow-react-proptypes"
212215
]
213216
}
214217
```

tutorial/05-redux-immutable-fetch.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ In this section we are going to create *Components* and *Containers*.
111111
```js
112112
// @flow
113113

114-
import React, { PropTypes } from 'react'
114+
import React from 'react'
115115

116116
type Props = {
117117
label: string,
@@ -121,11 +121,6 @@ type Props = {
121121
const Button = ({ label, handleClick }: Props) =>
122122
<button onClick={handleClick}>{label}</button>
123123

124-
Button.propTypes = {
125-
label: PropTypes.string.isRequired,
126-
handleClick: PropTypes.func.isRequired,
127-
}
128-
129124
export default Button
130125
```
131126

@@ -136,7 +131,7 @@ export default Button
136131
```js
137132
// @flow
138133

139-
import React, { PropTypes } from 'react'
134+
import React from 'react'
140135

141136
type Props = {
142137
message: string,
@@ -145,10 +140,6 @@ type Props = {
145140
const Message = ({ message }: Props) =>
146141
<p>{message}</p>
147142

148-
Message.propTypes = {
149-
message: PropTypes.string.isRequired,
150-
}
151-
152143
export default Message
153144
```
154145

0 commit comments

Comments
 (0)