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

Warn when defined methods are used in plain JS classes #2806

Merged
merged 1 commit into from
Jan 13, 2015

Conversation

sebmarkbage
Copy link
Collaborator

This is building on top of #2805

In ReactClass we use early validation to warn you if an accidentally defined
propTypes in the wrong place or if you mispelled componentShouldUpdate.

For plain JS classes there is no early validation process. Therefore, we
wait to do this validation until the component is mounted before we issue
the warning.

This should bring us to warning-parity with ReactClass.

In ReactClass we use early validation to warn you if a accidentally defined
propTypes in the wrong place or if you mispelled componentShouldUpdate.

For plain JS classes there is no early validation process. Therefore, we
wait to do this validation until the component is mounted before we issue
the warning.

This should bring us to warning-parity with ReactClass.
sebmarkbage added a commit that referenced this pull request Jan 13, 2015
Warn when defined methods are used in plain JS classes
@sebmarkbage sebmarkbage merged commit 7a3083a into facebook:master Jan 13, 2015
@zpao
Copy link
Member

zpao commented Jan 14, 2015

After trying to pull this internally, I realized just how noisy this is in a testing environment. I didn't see it before BUT you can see it yourself by running testing ReactMockedComponent-test. Since the component is mocked, it's being treated like a plain JS object (because it is). In our www stack that's super annoying. Can we silence this warning for the mocked component case?

@sebmarkbage
Copy link
Collaborator Author

It's probably because we use _isReactClassApproved = true which doesn't get moved onto the mock. We can hack around it by using _isReactClassApproved = {} in which case our mocking tools would move them over.

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

Successfully merging this pull request may close these issues.

2 participants