Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Fix issue with Node production environment and react-transition-group's PropTypes #21

Merged
merged 2 commits into from
Jan 30, 2019

Conversation

ScottMorse
Copy link
Contributor

This is my fix to a known issue, described below.

react-transition-group's custom PropTypes are set to null if the Node env is set to "production." This causes an Internal Server Error in Next.js, "Cannot read property 'isRequired' of null."

To fix this, I simply mirrored the react-transition-group's code by nullifying the prop type timeoutsShape only if process.env.NODE_ENV is "production".

With this fix, the PropType will still be applied in development and create the appropriate console errors.

`react-transition-group`'s custom PropTypes are null if the NODE_ENV is "production."  This causes an Internal Server Error in Next.js, "Cannot read property 'isRequired' of null." 

To fix this, I simply mirrored the react-transition-group's code by nullifying the prop type `timeoutsShape` only if `process.env.NODE_ENV` is "production".
I realized my previous commit fixed the problem but would have resulted in a console.error in production for any time that a  `loadingTimeout` prop was supplied.
@ScottMorse ScottMorse changed the title Fix issue with Node production envirnoment and react-transition-group's PropTypes Fix issue with Node production environment and react-transition-group's PropTypes Jan 30, 2019
@lyubchev
Copy link

Please merge this

Copy link
Member

@nwalters512 nwalters512 left a comment

Choose a reason for hiding this comment

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

It seems to be six to one, half dozen to the other with this and #18, but given that that one still has issues to be resolved and that this one more closely matches what react-transition-group is already doing, I'll go ahead and merge this. Thanks for the contribution!

There are some lingering prettier/linter concerns here, but that's half on me for not getting CI set up on this repo yet. I'll resolve all of that later 👍

@nwalters512 nwalters512 merged commit 74ae9d8 into illinois:master Jan 30, 2019
@ScottMorse
Copy link
Contributor Author

Glad to help! Love the package by the way. It makes Next.js so much more awesome. Makes route changes feel like a native app.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants