Skip to content

Commit

Permalink
Merge pull request #127 from omniscientjs/issue-126
Browse files Browse the repository at this point in the history
Expose `defaultProps` on component creator
  • Loading branch information
mikaelbr committed Nov 12, 2015
2 parents 41260c0 + 67fbd3f commit 4195b11
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 1 addition & 3 deletions component.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,7 @@ function factory (initialOptions) {
create = assign(create, methodStatics);
}

create.type = Component;

return create;
return assign(create, Component, { type: Component });
}
}

Expand Down
18 changes: 18 additions & 0 deletions tests/component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,24 @@ describe('component', function () {

Creator.type.should.equal(Type);
});

it('will pass default props', function () {
var expectedPropValue = 'default-prop-value';

var lifecycleMethods = {
getDefaultProps: function () {
return { direction: expectedPropValue };
}
};
var Component = component(lifecycleMethods, function (props) {
should.equal(props.direction, expectedPropValue);
this.props.direction.should.equal(expectedPropValue);
return DOM.div();
});

render(Component());
render(React.createElement(Component)); // jsx
});
});

describe('should not re-render', function () {
Expand Down

0 comments on commit 4195b11

Please sign in to comment.