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

Bind getDefaultProps to the class so statics can be read (#420) #421

Merged
merged 1 commit into from
Dec 25, 2017

Conversation

joeyrobert
Copy link
Contributor

@joeyrobert joeyrobert commented Aug 31, 2017

Fixes #420

src/index.js Outdated
@@ -424,7 +424,7 @@ function createClass(obj) {
cl.defaultProps = obj.defaultProps;
}
if (obj.getDefaultProps) {
cl.defaultProps = obj.getDefaultProps();
cl.defaultProps = obj.getDefaultProps.bind(cl)();
Copy link
Member

Choose a reason for hiding this comment

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

Would be much cheaper to use .call() here:

cl.defaultProps = obj.getDefaultProps.call(cl);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call ;) I've changed it to .call.

@developit developit merged commit 1f0e508 into preactjs:master Dec 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants