Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

propTypes #10

Open
Mstar0816 opened this issue Mar 3, 2024 · 2 comments
Open

propTypes #10

Mstar0816 opened this issue Mar 3, 2024 · 2 comments

Comments

@Mstar0816
Copy link
Owner

Force ReactJS to throw real errors when propTypes validation fails?

@Mstar0816
Copy link
Owner Author

At present, if propType validation fails, ReactJS uses console.warn to emit a warning. I really, really want a real error in dev mode, so it can fail our continuous integration build, instead of just printing a message that might be lost in the shuffle.

@Mstar0816
Copy link
Owner Author

There's already been discussion of this, e.g. in this feature request, and this related question describes the current behavior as expected. That's fine, but I personally want it to throw an error.
Assuming that ReactJS doesn't provide better support for this any time soon, what's the best workaround? So far, the best I've come up with is to override console.warn for tests, e.g.
console.warn = function(msg) {
throw new Error(msg);
};

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

No branches or pull requests

1 participant