diff --git a/packages/cli/src/api/parsers/babel.js b/packages/cli/src/api/parsers/babel.js index 99a6d4f6..3667c202 100644 --- a/packages/cli/src/api/parsers/babel.js +++ b/packages/cli/src/api/parsers/babel.js @@ -73,7 +73,7 @@ function toStr(children, counter = 0) { } } else if (child.type === 'JSXText') { // Child is not a React element, append as-is - const chunk = child.value.trim(); + const chunk = child.value.trim().replace(/\s+/g, ' '); if (chunk) { result.push(chunk); } } else if ( child.type === 'JSXExpressionContainer' diff --git a/packages/react/src/utils/toStr.js b/packages/react/src/utils/toStr.js index 1738e912..7da07fd9 100644 --- a/packages/react/src/utils/toStr.js +++ b/packages/react/src/utils/toStr.js @@ -64,7 +64,7 @@ export function toStr(children, counter = 0) { // Child is not a React element, append as-is /* eslint-disable no-lonely-if */ if (typeof child === 'string' || child instanceof String) { - const chunk = child.trim(); + const chunk = child.trim().replace(/\s+/g, ' '); if (chunk) { result.push(chunk); } } else { result.push(child);