Skip to content

Commit 7120daa

Browse files
author
denisp22
committed
Allow React component displayName and propTypes to be removed in production builds.
Fixes jaydenseric/graphql-react#51 .
1 parent 7f455df commit 7120daa

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Next
44

5+
### Minor
6+
7+
- Allow React component `displayName` and `propTypes` to be removed in production builds, fixing [#51](https://github.com/jaydenseric/graphql-react/issues/51).
8+
59
### Patch
610

711
- Updated dependencies.

src/universal/GraphQLContext.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const React = require('react');
4141
*/
4242
const GraphQLContext = React.createContext();
4343

44-
GraphQLContext.displayName = 'GraphQLContext';
44+
if (typeof process === 'object' && process.env.NODE_ENV !== 'production')
45+
GraphQLContext.displayName = 'GraphQLContext';
4546

4647
module.exports = GraphQLContext;

src/universal/GraphQLProvider.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ function GraphQLProvider({ graphql, children }) {
5757
);
5858
}
5959

60-
GraphQLProvider.propTypes = {
61-
graphql: PropTypes.instanceOf(GraphQL).isRequired,
62-
children: PropTypes.node,
63-
};
60+
if (typeof process === 'object' && process.env.NODE_ENV !== 'production')
61+
GraphQLProvider.propTypes = {
62+
graphql: PropTypes.instanceOf(GraphQL).isRequired,
63+
children: PropTypes.node,
64+
};
6465

6566
module.exports = GraphQLProvider;

src/universal/private/FirstRenderDateContext.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const React = require('react');
1313
*/
1414
const FirstRenderDateContext = React.createContext();
1515

16-
FirstRenderDateContext.displayName = 'FirstRenderDateContext';
16+
if (typeof process === 'object' && process.env.NODE_ENV !== 'production')
17+
FirstRenderDateContext.displayName = 'FirstRenderDateContext';
1718

1819
module.exports = FirstRenderDateContext;

0 commit comments

Comments
 (0)