These are chat archives for chandu0101/scalajs-react-components

9th
Feb 2016
Alexej Haak
@Daxten
Feb 09 2016 09:39
hm MuiIconButton doesnt have any onclick or onTouchTap method anymore
Alexej Haak
@Daxten
Feb 09 2016 10:12
MuiTextField(
  onChange = { e: ReactEventI => Callback.info(e.currentTarget.value) >> Callback.info(e.target.value)
)
both create "cant read value "value" of null"
ah
currentTarget works sorry
          onChange = { e: ReactEventI =>
            $.modState(_.copy(task = Some(e.target.value)
          )) }
          onChange = { e: ReactEventI =>
            val value = e.target.value
            $.modState(_.copy(task = Some(value)
          )) }
first one doesn't work (target is null), second one works
Øyvind Raddum Berg
@oyvindberg
Feb 09 2016 10:18
goddamn javascript apis, why cant they just shield us from that event madness and give us the string
and yeah, that makes MuiIconButton pretty much unusable for now, unfortunately
for the other buttons i marked them as descendants of EnhancedButton, so they inherit all the event handlers from there, should do the same for MuiIconButton
Alexej Haak
@Daxten
Feb 09 2016 10:23
yeah :(
in the last version we didn't have that problem
(with the events)
but that must be a change in mui I guess
onFocus works as a workaround for MuiIconButton.. but that's not optimal :)
Alexej Haak
@Daxten
Feb 09 2016 10:38
can't I curry in scalajs??
  def useValue(f: String => Callback)(e: ReactEventI): Callback = {
    val value = e.target.value
    f(value)
  }

onChange = useValue { value => $.modState(_.copy(task = value)) }

missing arguments for method useValue in trait ReactHelper;
follow this method with `_' if you want to treat it as a partially applied function
wrong chat room maybe
Øyvind Raddum Berg
@oyvindberg
Feb 09 2016 11:15
wrong room i guess yeah, but you can just like in scala
you need to add that _ at the end, unless youre in a context where the compiler expects a function
some of my event handler code broke with react 0.14.7 and material-ui 0.14.4 too, out of the blue i needed to persist() events, or the browser would have taken away the content
no idea what went wrong there
Alexej Haak
@Daxten
Feb 09 2016 11:31
ah, so I guess the undefOr breaks the "context where the compiler expects a function", I just rewritten it to return exactly what is needed in the function and it works that way
Øyvind Raddum Berg
@oyvindberg
Feb 09 2016 11:47
exactly right
you could solve it in many ways, but its really another irritation with how scala infers these things