You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Layout is React component. I am expecting to access propTypes.direction property of Layout component. This works in development environment. However, because propTypes are stripped in production, I am getting an error:
Uncaught (in promise) TypeError: Cannot read property 'direction' of undefined(…)
The only fix that I can think of in user land is adding a safe-check that eliminates the dead-code during the build stage, e.g.
However, because propTypes are stripped in production, I am getting an error
PropTypes are not currently stripped in production. There was a proposal for this (#6401) but we haven’t agreed on it, and in any case, it’s not there in 0.14.x or 15.x.
React does not call your propTypes in production, but if you defined them, they will stay there. If propTypes declarations get stripped from your builds, it’s because you specifically choose to do this (e.g. via a Babel plugin). This is not the default behavior of React, so I’ll close this as this is unactionable for us.
I am aware that:
https://facebook.github.io/react/docs/reusable-components.html#prop-validation
In development mode, we have "models": collections of
propTypes
, e.g.Layout
is React component. I am expecting to accesspropTypes.direction
property ofLayout
component. This works in development environment. However, becausepropTypes
are stripped in production, I am getting an error:The only fix that I can think of in user land is adding a safe-check that eliminates the dead-code during the build stage, e.g.
This is sub-optimal, because it would require updating each instance where
propTypes
are used to declare data shapes.propTypes
but disable validation?The text was updated successfully, but these errors were encountered: