Skip to content

Commit

Permalink
Allow React component displayName and propTypes to be removed in prod…
Browse files Browse the repository at this point in the history
…uction builds.

Fixes #51 .
  • Loading branch information
jaydenseric committed Sep 17, 2020
1 parent 1c52c2c commit 32c5c4f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Next

### Minor

- Allow React component `displayName` and `propTypes` to be removed in production builds, fixing [#51](https://github.com/jaydenseric/graphql-react/issues/51).

### Patch

- Updated dependencies.
Expand Down
3 changes: 2 additions & 1 deletion src/universal/GraphQLContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const React = require('react');
*/
const GraphQLContext = React.createContext();

GraphQLContext.displayName = 'GraphQLContext';
if (typeof process === 'object' && process.env.NODE_ENV !== 'production')
GraphQLContext.displayName = 'GraphQLContext';

module.exports = GraphQLContext;
9 changes: 5 additions & 4 deletions src/universal/GraphQLProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ function GraphQLProvider({ graphql, children }) {
);
}

GraphQLProvider.propTypes = {
graphql: PropTypes.instanceOf(GraphQL).isRequired,
children: PropTypes.node,
};
if (typeof process === 'object' && process.env.NODE_ENV !== 'production')
GraphQLProvider.propTypes = {
graphql: PropTypes.instanceOf(GraphQL).isRequired,
children: PropTypes.node,
};

module.exports = GraphQLProvider;
3 changes: 2 additions & 1 deletion src/universal/private/FirstRenderDateContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const React = require('react');
*/
const FirstRenderDateContext = React.createContext();

FirstRenderDateContext.displayName = 'FirstRenderDateContext';
if (typeof process === 'object' && process.env.NODE_ENV !== 'production')
FirstRenderDateContext.displayName = 'FirstRenderDateContext';

module.exports = FirstRenderDateContext;

0 comments on commit 32c5c4f

Please sign in to comment.