Skip to content

Commit 5a2352c

Browse files
committed
Use static propTypes
1 parent 6dc8ade commit 5a2352c

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

.babelrc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
"stage-1",
55
"react"
66
],
7-
"plugins": [
8-
"babel-plugin-dev-expression"
9-
]
7+
"env": {
8+
"production": {
9+
"plugins": [
10+
"dev-expression",
11+
"transform-react-remove-prop-types"
12+
]
13+
}
14+
}
1015
}

modules/Broadcast.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ const createBroadcast = (initialValue) => {
3737
* <Subscriber> component for a reference implementation.
3838
*/
3939
class Broadcast extends React.Component {
40+
static propTypes = {
41+
channel: PropTypes.string.isRequired,
42+
children: PropTypes.node.isRequired,
43+
value: PropTypes.any
44+
}
45+
4046
static contextTypes = {
4147
broadcasts: PropTypes.object
4248
}
@@ -78,12 +84,4 @@ class Broadcast extends React.Component {
7884
}
7985
}
8086

81-
if (__DEV__) {
82-
Broadcast.propTypes = {
83-
channel: PropTypes.string.isRequired,
84-
children: PropTypes.node.isRequired,
85-
value: PropTypes.any
86-
}
87-
}
88-
8987
export default Broadcast

modules/Subscriber.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import React, { PropTypes } from 'react'
66
* and passes it to its children function.
77
*/
88
class Subscriber extends React.Component {
9+
static propTypes = {
10+
channel: PropTypes.string.isRequired,
11+
children: PropTypes.func.isRequired
12+
}
13+
914
static contextTypes = {
1015
broadcasts: PropTypes.object
1116
}
@@ -50,11 +55,4 @@ class Subscriber extends React.Component {
5055
}
5156
}
5257

53-
if (__DEV__) {
54-
Subscriber.propTypes = {
55-
channel: PropTypes.string.isRequired,
56-
children: PropTypes.func.isRequired
57-
}
58-
}
59-
6058
export default Subscriber

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"babel-eslint": "^7.0.0",
3131
"babel-loader": "^6.2.4",
3232
"babel-plugin-dev-expression": "^0.2.1",
33+
"babel-plugin-transform-react-remove-prop-types": "^0.2.11",
3334
"babel-preset-es2015": "^6.9.0",
3435
"babel-preset-es2015-loose": "^8.0.0",
3536
"babel-preset-react": "^6.5.0",

0 commit comments

Comments
 (0)