cca-io / rescript-mui

ReScript bindings for MUI
MIT License
254 stars 52 forks source link

Grid.spacing not working #179

Closed FilipKittnar closed 2 years ago

FilipKittnar commented 2 years ago

Hello, I think there is a serious bug in version 3 with Grid component and the prop "spacing". It is defined like this:

  ~spacing: @int
  [
    | @as(0) #0
    | @as(1) #1
    | @as(2) #2
    | @as(3) #3
    | @as(4) #4
    | @as(5) #5
    | @as(6) #6
    | @as(7) #7
    | @as(8) #8
    | @as(9) #9
    | @as(10) #10
  ]=?,

But if you use for example spacing=#2, it is transpiled to this:

                              switch (2) {
                                case "0" :
                                    return 0;
                                case "1" :
                                    return 1;
                                case "2" :
                                    return 2;
                                case "3" :
                                    return 3;
                                case "4" :
                                    return 4;
                                case "5" :
                                    return 5;
                                case "6" :
                                    return 6;
                                case "7" :
                                    return 7;
                                case "8" :
                                    return 8;
                                case "9" :
                                    return 9;
                                case "10" :
                                    return 10;

                              }

So the spacing doesn't work at all.

FilipKittnar commented 2 years ago

Hello, so the solution seems to be simply:

~spacing: [
    | #0
    | #1
    | #2
    | #3
    | #4
    | #5
    | #6
    | #7
    | #8
    | #9
    | #10
  ]=?,
fhammerschmidt commented 2 years ago

Thank you for reporting this. Indeed this was one missed simplification in the binding generator, I fixed it now and will release a version 3.0.2 today.