Omniscient 4.1.0 breaks getDefaultProps
ChristiaanScheermeijer opened this issue · comments
After the 4.1.0 update React components don't receive the default props anymore from the getDefaultProps()
lifecycle method. After some debugging we've found out that there goes something wrong in the .type
assignment of the component.
create.type = Component;
This results in a Component with 2 types nested component.type.type
where the defaultProps are defined. React.createElement
only looks in the first type
for the defaultProps object.
Damn. Sorry about that!
It looked to good to be true, so it usually is. We'll look into this asap. Do you mind providing an example to reproduce the issue you are seeing? We'll convert it to a test and make it pass.
@mikaelbr maybe we ought to look into create.prototype = Component.prototype
instead as mentioned in #125
No problem :-)
var lifecycleMethods = {
getDefaultProps: function () {
return {
direction: 'vertical'
};
}
};
module.exports = component(lifecycleMethods, function ({ children, direction, ...rest }) {
// direction is only defined when given as prop
console.log(direction);
// same for this.props
console.log(this.props);
return <div { ...rest }>{ children }</div>
});
This is still an issue after removing create.type
, the jsx assert fails 41260c0...issue-126#diff-85be81e3538eeba3d115e6ea83f12809R749
This results in a Component with 2 types nested component.type.type where the defaultProps are defined
Yeah, this is unfortunate, but "intentional" to resolve an issue with omniscient and jsx w/react 0.14.
I'm suspecting you never got any getDefaultProps
after omniscient@4? A fix is in master, expect a patch any minute
This should be fixed in the patch release omniscient@4.1.1
! Hope this works better for you.