Skip to content

Commit

Permalink
fix: handle <div>{123}</div>
Browse files Browse the repository at this point in the history
fixes #8
  • Loading branch information
vvo committed Nov 8, 2015
1 parent eaca1a2 commit 609ac78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,4 +390,12 @@ describe(`reactElementToJSXString(ReactElement)`, () => {
reactElementToJSXString(<div>{null}</div>)
).toEqual(`<div />`);
});

it(`reactElementToJSXString(<div>{123}</div>)`, () => {
expect(
reactElementToJSXString(<div>{123}</div>)
).toEqual(`<div>
123
</div>`);
});
});
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function reactElementToJSXString(ReactElement) {
}

function toJSXString({ReactElement = null, lvl = 0, inline = false}) {
if (typeof ReactElement === 'string') {
if (typeof ReactElement === 'string' || typeof ReactElement === 'number') {
return ReactElement;
} else if (!isElement(ReactElement)) {
throw new Error('react-element-to-jsx-string: Expected a ReactElement, ' +
Expand Down

0 comments on commit 609ac78

Please sign in to comment.