Reason: [refmt] Block formatting in JSX

Created on 13 Dec 2018  路  9Comments  路  Source: reasonml/reason

Input:

<div>
  {
    let left = (limit - value->Js.String.length)->Int.toString;
    {j|$left characters left|j}->React.string;
  }
</div>

Output:

<div>
  {let left = (limit - value->Js.String.length)->Int.toString
   {j|$left characters left|j}->React.string}
</div>
HIGH PRI BUG Printer

Most helpful comment

@bloodyowl yes, I have the solution locally, will make a PR tomorrow when I'm back at laptop.

All 9 comments

In my case (using bs-platform 4.0.8), I am getting this thing reformatted

<View style=styles##backgroundImageWrapper>
  {
    let uri = "/images/header-background.png";
    <Image
      resizeMode=`contain
      style=styles##backgroundImage
      source={`URI(Image.(imageURISource(~uri, ())))}
      /* SSR workaround https://github.com/necolas/react-native-web/issues/543 */
      defaultSource={`URI(Image.(defaultURISource(~uri, ())))}
    />
  }
</View>

to

<View style=styles##backgroundImageWrapper>
  {let uri = "/images/header-background.png"
    <Image
      resizeMode=`contain
      style=styles##backgroundImage
      source={`URI(Image.(imageURISource(~uri, ())))}
      /* SSR workaround https://github.com/necolas/react-native-web/issues/543 */
      defaultSource={`URI(Image.(defaultURISource(~uri, ())))}
    />}
</View>

And then the new code generate an error

Error: Syntax error: expression after infix operator expected.

Note: the initial snippet was perfectly working with bs-platform 4.0.6

I'm looking into the issue.

@anmonteiro would you mind taking this one?
I came to the following solution, but I'm not sure if this is the right solution
image

@IwanKaramazow I just tried it locally. That does indeed seem like the right fix here.

is there any progress on this?

@bloodyowl yes, I have the solution locally, will make a PR tomorrow when I'm back at laptop.

Is there a workaround for this before that I can use before we get a bs-platform release that includes the fix?

PR with fix is up at https://github.com/facebook/reason/pull/2319.
Sorry for the delay!

Fantastic, thank you @IwanKaramazow!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bluddy picture bluddy  路  3Comments

jberdine picture jberdine  路  3Comments

kyldvs picture kyldvs  路  3Comments

rickyvetter picture rickyvetter  路  4Comments

TrakBit picture TrakBit  路  3Comments