Skip to content

Commit

Permalink
Add .propTypes and .displayName assignments with __DEV__ check
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Nov 22, 2019
1 parent 5e0c50d commit 12243e1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ module.exports = {
'@babel/transform-react-jsx',
cjs && ['@babel/transform-modules-commonjs', { loose }],
['@babel/transform-runtime', { useESModules: !cjs }],
].filter(Boolean),
'dev-expression'
].filter(Boolean)
}
6 changes: 2 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@
"mocha": true,
"node": true
},
"globals": { "__DEV__": "readonly" },
"rules": {
"valid-jsdoc": 2,
"react/jsx-uses-react": 1,
"react/jsx-no-undef": 2,
"react/jsx-wrap-multilines": 2,
"react/no-string-refs": 0
},
"plugins": [
"import",
"react"
]
"plugins": ["import", "react"]
}
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"@testing-library/react-native": "^4.2.0",
"babel-eslint": "^10.0.3",
"babel-jest": "^24.9.0",
"babel-plugin-dev-expression": "^0.2.2",
"codecov": "^3.5.0",
"create-react-class": "^15.6.3",
"cross-env": "^5.2.0",
Expand Down
6 changes: 4 additions & 2 deletions src/components/Context.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react'

export const ReactReduxContext = React.createContext(null)
export const ReactReduxContext = /*#__PURE__*/ React.createContext(null)

ReactReduxContext.displayName = 'ReactRedux'
if (__DEV__) {
ReactReduxContext.displayName = 'ReactRedux'
}

export default ReactReduxContext
18 changes: 10 additions & 8 deletions src/components/Provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ function Provider({ store, context, children }) {
return <Context.Provider value={contextValue}>{children}</Context.Provider>
}

Provider.propTypes = {
store: PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired
}),
context: PropTypes.object,
children: PropTypes.any
if (__DEV__) {
Provider.propTypes = {
store: PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired
}),
context: PropTypes.object,
children: PropTypes.any
}
}

export default Provider

0 comments on commit 12243e1

Please sign in to comment.