diff --git a/README.md b/README.md index 44ae1b2a3..76f3dd0d8 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,6 @@ Features: - sort object keys in a deterministic order (`o={{a: 1, b:2}} === o={{b:2, a:1}}`) - handle `ref` and `key` attributes, they are always on top of props - React's documentation indent style for JSX -- Display whitespace as `` when needed diff --git a/index-test.js b/index-test.js index 996dd56b4..d513190be 100644 --- a/index-test.js +++ b/index-test.js @@ -382,9 +382,7 @@ describe(`reactElementToJSXString(ReactElement)`, () => { it(`reactElementToJSXString(
{false}
)`, () => { expect( reactElementToJSXString(
{false}
) - ).toEqual(`
- -
`); + ).toEqual(`
\n \n
`); }); it(`reactElementToJSXString(
{null}
)`, () => { diff --git a/index.js b/index.js index d456e86f6..320e13885 100644 --- a/index.js +++ b/index.js @@ -33,8 +33,7 @@ function toJSXString({ReactElement = null, lvl = 0, inline = false}) { let props = formatProps(ReactElement.props); let attributes = []; let children = React.Children.toArray(ReactElement.props.children) - .filter(onlyMeaningfulChildren) - .map(displayWhitespace); + .filter(onlyMeaningfulChildren); if (ReactElement.ref !== null) { attributes.push(getJSXAttribute('ref', ReactElement.ref)); @@ -192,11 +191,3 @@ function noChildren(propName) { function onlyMeaningfulChildren(children) { return children !== true && children !== false && children !== null; } - -function displayWhitespace(children) { - if (children === ' ') { - return ''; - } - - return children; -}