Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Only run proptypes checks on element creation like React. #370

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tkh44
Copy link
Contributor

@tkh44 tkh44 commented Apr 25, 2017

No description provided.

) {
props.children = vnode.children;
}
propsHook(props);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought: does this need to be called even if DEV=false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually called all the time. see here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I see what you mean now. 🤔 I don't think so. I could have sworn we fixed this a while back but I can't find where.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not an issue. We are rearranging the props so that prop-types detects the children correctly.

@developit
Copy link
Member

This is a reminder for myself to merge

@tkh44
Copy link
Contributor Author

tkh44 commented Jun 16, 2017

@developit do you still want to merge this? Is there something concerning you about this?

@developit
Copy link
Member

Yup, I'm just insanely bad at keeping up with PRs right now

Copy link
Member

@developit developit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LMK on comments

@@ -270,10 +270,35 @@ function statelessComponentHook(Ctor) {
return Wrapped;
}

function validatePropTypes (vnode) {
if (DEV) {
let componentClass = typeof vnode.nodeName === "function"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can just always look at vnode.nodeName, right?


function createElement(...args) {
upgradeToVNodes(args, 2);
return normalizeVNode(h(...args));
let node = h(...args);
validatePropTypes(node);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just had a thought (I think I was noodling on this when I failed to review before):

What if we moved the invocation of this validation into handleComponentVNode()? That would make proptype validation work in non-compat components if you install compat, which is kinda compelling. Also it would nicely reuse the existing logic around detecting and forking for component VNodes vs element VNodes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly got this working in a very specific way and I don't remember all the details. I do remember that I had good reasons for doing it the way I did though 😅

@developit developit added this to To Do in Backlog via automation Jan 30, 2018
@developit developit self-assigned this Feb 23, 2018
@developit developit added this to the 3.19 milestone Feb 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Backlog
  
To Do
Development

Successfully merging this pull request may close these issues.

None yet

2 participants