Skip to content

Commit

Permalink
Fix bug where children were not used
Browse files Browse the repository at this point in the history
Closes GH-18.
  • Loading branch information
wooorm committed Jul 12, 2019
1 parent 16c7909 commit dc9b80f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function rehypeReact(options) {
res.type === 'div' &&
(node.children.length !== 1 || node.children[0].type !== 'element')
) {
res = res.children
res = res.props.children
} else {
res = [res]
}
Expand Down
5 changes: 3 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ test('React ' + React.version, function(t) {
createElement: React.createElement,
Fragment: React.Fragment
})
.stringify(u('root', [h('p')])),
.stringify(u('root', [h('h1'), h('p')])),
React.createElement(React.Fragment, {}, [
React.createElement('p', {key: 'h-1'}, undefined)
React.createElement('h1', {key: 'h-2'}, undefined),
React.createElement('p', {key: 'h-3'}, undefined)
]),
'should transform `root` to a `Fragment` if given'
)
Expand Down

0 comments on commit dc9b80f

Please sign in to comment.