Skip to content

Conversation

@zpao
Copy link
Member

@zpao zpao commented Dec 16, 2014

This adds a warning to React.createElement in DEV about using null
or undefined. This is technically valid since element creation can be
considered safe and usable in multiple rendering environments. But
rendering in a DOM environment with an element with null/undefined type
is not safe.

Fixes #2607

@zpao
Copy link
Member Author

zpao commented Dec 16, 2014

Based on #2607 if we take this we should backport to 0.12

@zpao zpao force-pushed the createElement-undefined-null branch from 2eb6299 to 6640471 Compare December 16, 2014 22:49
@zpao
Copy link
Member Author

zpao commented Dec 16, 2014

Updated after talking to @sebmarkbage - creating the element should apparently be allowed (since in theory it's totally possible to create an element literal with undefined type), though we may throw when rendering. We'll warn in DEV (thus the use of ReactElementValidator) but not in prod.

Copy link
Collaborator

Choose a reason for hiding this comment

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

rm

This adds a warning to React.createElement in __DEV__ about using null
or undefined. This is technically valid since element creation can be
considered safe and usable in multiple rendering environments. But
rendering in a DOM environment with an element with null/undefined type
is not safe.
@zpao zpao force-pushed the createElement-undefined-null branch from 6640471 to 50a0d69 Compare December 17, 2014 18:39
zpao added a commit that referenced this pull request Dec 17, 2014
Protect better against createElement(null/undefined)
@zpao zpao merged commit 626023f into facebook:master Dec 17, 2014
@zpao zpao added this to the 0.12.2 milestone Dec 18, 2014
zpao added a commit to zpao/react that referenced this pull request Dec 18, 2014
Protect better against createElement(null/undefined)
Conflicts:
	src/classic/element/__tests__/ReactElementValidator-test.js
@zpao zpao deleted the createElement-undefined-null branch April 16, 2015 16:43
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.

Making React warn the user when createElement is called with undefined for the type argument

2 participants