Skip to content

Commit

Permalink
Wrap .propTypes and .displayName assignments with __DEV__ check (#1471)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist authored and timdorr committed Nov 23, 2019
1 parent 5e0c50d commit 9fc5993
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
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 (process.env.NODE_ENV !== 'production') {
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 (process.env.NODE_ENV !== 'production') {
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

2 comments on commit 9fc5993

@TrejGun
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just in case you are not aware
https://www.npmjs.com/package/babel-plugin-transform-react-remove-prop-types
I can make a PR if you agree

@timdorr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I would rather have this be explicit. Thanks, though!

Please sign in to comment.