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

Inline propTypes checking code #15

Merged
merged 1 commit into from
Feb 28, 2020
Merged

Inline propTypes checking code #15

merged 1 commit into from
Feb 28, 2020

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Feb 28, 2020

The propTypes checking contract hasn't changed for years. It's stable.

Its source of truth lives in the prop-types package. However, we are inlining it in the React repo (facebook/react#18127) to simplify React's ES Modules adoption story. We will do the same with the Object.assign polyfill. This PR mirrors the same change for the shallow renderer, too.

The goal is to get to a place where none of our transitive dependencies require CommonJS for bundling.

The other change here is that I reuse the existing React's mechanism for injecting the stack. Previously, shallow renderer did a special thing, which only worked for propTypes. Now we use a generic mechanism so if you call, for example, React.createElement, it will also get the right stack.

Easier to review without whitespace: https://github.com/NMinhNguyen/react-shallow-renderer/compare/inline-pt?w=1

@NMinhNguyen NMinhNguyen merged commit 2e59ba1 into master Feb 28, 2020
@NMinhNguyen NMinhNguyen deleted the inline-pt branch February 28, 2020 02:51
@NMinhNguyen
Copy link
Collaborator

This is great, thank you!

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

Successfully merging this pull request may close these issues.

2 participants