jsx-to-string icon indicating copy to clipboard operation
jsx-to-string copied to clipboard

Option to put props on single line

Open dwoznicki opened this issue 6 years ago • 0 comments

Hi, cool library. It turned out to be exactly what I was looking for today. Anyway, I noticed that the JSX string adds line breaks between props when the component has children. This leads to somewhat awkward looking strings.

For example,

jsxToString(<Something propA propB>Another thing</Something>, {
  shortBooleanSyntax: true
});
/*
Outputs:
<Something propA
    propB>
    Another thing
</Something>
*/

My proposal is to add an option to put props on one line. For example,

jsxToString(<Something propA propB>Another thing</Something>, {
  shortBooleanSyntax: true,
  singleLineProps: true
});
/*
Outputs:
<Something propA propB>
    Another thing
</Something>
*/

It looks like a pretty simple fix, so I may just go ahead and submit a PR.

dwoznicki avatar Jan 01 '19 07:01 dwoznicki