GithubHelp home page GithubHelp logo

Comments (10)

gaearon avatar gaearon commented on May 5, 2024 8

This was an intentional breaking change inprop-types itself (as it is a completely new package) but I didn’t fully realize we switched React 15.5 to actually use the prop-types (and thus trigger the error).

We need to put out a fix for this asap, thanks for reporting.

from prop-types.

gaearon avatar gaearon commented on May 5, 2024 3

Fixed in [email protected].

from prop-types.

franjohn21 avatar franjohn21 commented on May 5, 2024 1

Codepen: http://codepen.io/franjohn21/pen/Wjeemd

from prop-types.

franjohn21 avatar franjohn21 commented on May 5, 2024 1

If I'm reading the docs correctly, this functionality should throw an error in a future major release.

In a future major release of React, the code that implements PropType validation functions will be stripped in production. Once this happens, any code that calls these functions manually (that isn't stripped in production) will throw an error.

So throwing an error now is unintentional and breaks production builds particularly where 3rd party libraries manually called proptype functions.

from prop-types.

Daniel15 avatar Daniel15 commented on May 5, 2024

This seems to be an intentional design choice. From the readme in this repo:

In production, all validator functions are replaced with empty functions that throw an error. This is done to optimize the bundle size.

I suspect the reasoning is that proptype checks are usually only done in development. However, I wonder why it doesn't just become a no-op in production, rather than throwing 😕

from prop-types.

aweary avatar aweary commented on May 5, 2024

Maybe @acdlite or @gaearon can shed some light on why prop-types is throwing in production before the next major React release.

from prop-types.

gaearon avatar gaearon commented on May 5, 2024

This is fixed in [email protected] and we'll update React 15.x to enforce depending on it soon.
In the meantime you should be able to run rm -rf node_modules and npm install to fix this.

from prop-types.

gaearon avatar gaearon commented on May 5, 2024

In case anyone is confused, the intended behavior is explained here:

https://github.com/reactjs/prop-types/blob/master/README.md#difference-from-reactproptypes-dont-call-validator-functions

I verified that [email protected] restores the old behavior for React.PropTypes, fixing the [email protected] problem.

from prop-types.

bvaughn avatar bvaughn commented on May 5, 2024

[email protected] ^

from prop-types.

gaearon avatar gaearon commented on May 5, 2024

Thanks 😄 I keep typing that for some reason

from prop-types.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.