Prettier-vscode: Wrong .tsx formatting with fragments

Created on 27 Nov 2018  路  6Comments  路  Source: prettier/prettier-vscode

this code

```jsx
import React from "react";

const Buddies = () => <>Buddies;
export default Buddies;
````

after saving becomes this

````jsx
import React from "react";

const Buddies = () => <>"uddie";
export default Buddies;
````

if i use a div instead of a fragment it works ok

prettier ran from command line works ok too

locked

Most helpful comment

I am also facing same issue! Following code:

<><div>abc</div></>

becomes:

<>
  ' \' \' \' \' '<div>abc</div>' '
</>

All 6 comments

I am having this problem too. In my case, this code:

<>
  <SafeAreaView style={styles.statusBar} />
  <SafeAreaView style={styles.safeArea}>{children}</SafeAreaView>
</>

Is becoming this:

<>'   '<SafeAreaView style={styles.statusBar} />'   '<SafeAreaView style={styles.safeArea}>{children}</SafeAreaView>' '</>

If I use React.Fragment explicitly, it works, but not with the empty tag.

I am also facing same issue! Following code:

<><div>abc</div></>

becomes:

<>
  ' \' \' \' \' '<div>abc</div>' '
</>

As a temporary solution, to turn off prettier.eslintIntegration fixes this issue.

settings.json { "prettier.eslintIntegration": false }

any update?

Duplicate of #870

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bajtos picture bajtos  路  4Comments

bardware picture bardware  路  4Comments

vesper8 picture vesper8  路  3Comments

Connorelsea picture Connorelsea  路  4Comments

sebastijandumancic picture sebastijandumancic  路  4Comments