search

Home  >  Q&A  >  body text

Prettier removed curly brackets "{ }" in .jsx file

I have the following code block in my .jsx file:

<div className="">
        <h1 className="">
          The Next <br className="sm:block hidden" /> {" "}
          <span className="text-gradient">Generation </span> {" "}
          Payment
        </h1>
      </div>

But prettier will remove the second {" "}, like this:

<div className="">
        <h1 className="">
          The Next <br className="sm:block hidden" /> {" "}
          <span className="text-gradient">Generation </span>
          Payment
        </h1>
      </div>

It will also remove {" "} in other parts of the code. If anyone can help me solve this problem I would be very grateful.

The only solution I found was to use prettier.bracketSpacing in the configuration of prettier, but that didn't help.

P粉760675452P粉760675452258 days ago467

reply all(1)I'll reply

  • P粉983021177

    P粉9830211772024-04-04 00:50:04

    Try this:

    const space = " ";
    return ( ...
    <div className="">
       <h1 className="">
           下一代<br className="sm:block hidden" /> {space}
           <span className="text-gradient">支付</span> {space}
           付款
       </h1>
    </div>

    reply
    0
  • Cancelreply