Skip to content

Commit 12243e1

Browse files
committed
Add .propTypes and .displayName assignments with __DEV__ check
1 parent 5e0c50d commit 12243e1

File tree

6 files changed

+25
-15
lines changed

6 files changed

+25
-15
lines changed

.babelrc.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ module.exports = {
1010
'@babel/transform-react-jsx',
1111
cjs && ['@babel/transform-modules-commonjs', { loose }],
1212
['@babel/transform-runtime', { useESModules: !cjs }],
13-
].filter(Boolean),
13+
'dev-expression'
14+
].filter(Boolean)
1415
}

.eslintrc

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@
2424
"mocha": true,
2525
"node": true
2626
},
27+
"globals": { "__DEV__": "readonly" },
2728
"rules": {
2829
"valid-jsdoc": 2,
2930
"react/jsx-uses-react": 1,
3031
"react/jsx-no-undef": 2,
3132
"react/jsx-wrap-multilines": 2,
3233
"react/no-string-refs": 0
3334
},
34-
"plugins": [
35-
"import",
36-
"react"
37-
]
35+
"plugins": ["import", "react"]
3836
}

package-lock.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"@testing-library/react-native": "^4.2.0",
7272
"babel-eslint": "^10.0.3",
7373
"babel-jest": "^24.9.0",
74+
"babel-plugin-dev-expression": "^0.2.2",
7475
"codecov": "^3.5.0",
7576
"create-react-class": "^15.6.3",
7677
"cross-env": "^5.2.0",

src/components/Context.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React from 'react'
22

3-
export const ReactReduxContext = React.createContext(null)
3+
export const ReactReduxContext = /*#__PURE__*/ React.createContext(null)
44

5-
ReactReduxContext.displayName = 'ReactRedux'
5+
if (__DEV__) {
6+
ReactReduxContext.displayName = 'ReactRedux'
7+
}
68

79
export default ReactReduxContext

src/components/Provider.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ function Provider({ store, context, children }) {
3333
return <Context.Provider value={contextValue}>{children}</Context.Provider>
3434
}
3535

36-
Provider.propTypes = {
37-
store: PropTypes.shape({
38-
subscribe: PropTypes.func.isRequired,
39-
dispatch: PropTypes.func.isRequired,
40-
getState: PropTypes.func.isRequired
41-
}),
42-
context: PropTypes.object,
43-
children: PropTypes.any
36+
if (__DEV__) {
37+
Provider.propTypes = {
38+
store: PropTypes.shape({
39+
subscribe: PropTypes.func.isRequired,
40+
dispatch: PropTypes.func.isRequired,
41+
getState: PropTypes.func.isRequired
42+
}),
43+
context: PropTypes.object,
44+
children: PropTypes.any
45+
}
4446
}
4547

4648
export default Provider

0 commit comments

Comments
 (0)