Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Commit

Permalink
Change string component creation using React.createElement (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiaocchiuto authored and istarkov committed Jan 28, 2017
1 parent c68853e commit dcc6f05
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/packages/recompose/__tests__/toClass-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ test('toClass passes context and props correctly', t => {

test('toClass works with strings (DOM components)', t => {
const Div = toClass('div')
const div = mount(<Div>Hello</Div>).find('div')
t.is(div.text(), 'Hello')
const div = mount(<Div>Hello</Div>)
t.is(div.html(), '<div>Hello</div>')
})
2 changes: 1 addition & 1 deletion src/packages/recompose/toClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const toClass = baseComponent => {
class ToClass extends Component {
render() {
if (typeof baseComponent === 'string') {
return <baseComponent {...this.props} />
return React.createElement(baseComponent, this.props)
}
return baseComponent(this.props, this.context)
}
Expand Down

0 comments on commit dcc6f05

Please sign in to comment.