-
Notifications
You must be signed in to change notification settings - Fork 48.5k
Minimal implementation of stateless components #4587
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
Conversation
Shouldn't be much change. Notably, this calls `.getName()` instead of trying to derive it manually, which is more consistent.
cc @sebmarkbage @vslinko: Thanks for your work in #3995. We're planning to go with a minimal implementation for now but let's keep your other PR open to see if we want to pull it in for 0.15. |
Stateless pure-function components give us more opportunity to make performance optimizations. For now, we'll do a minimal implementation which has similar performance characteristics to other components in the interests of shipping 0.14 and allowing people to begin writing code using this pattern; in the future we can refactor to allocate less and avoid other unnecessary work.
998129a
to
5a7bd96
Compare
@spicyj ok, agreed |
lgtm |
Minimal implementation of stateless components
inst = new Component(publicProps, publicContext, ReactUpdateQueue); | ||
} | ||
|
||
if (inst === null || inst === false || ReactElement.isValidElement(inst)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work because the construct trap will intercept any non-object and turn it into this
. :(
@spicyj I'm not sure: are there plans for the stateless function component to be handled as being pure and thus avoiding repeated calls (to render the output) if the properties provided stay unchanged (with respect to a |
@epsitec You can read the relevant discussion is here: #3995 (comment) |
Stateless pure-function components give us more opportunity to make performance optimizations. For now, we'll do a minimal implementation which has similar performance characteristics to other components in the interests of shipping 0.14 and allowing people to begin writing code using this pattern; in the future we can refactor to allocate less and avoid other unnecessary work.
This adapts @vslinko's tests from #3995.