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

10th
May 2017
TR
@torstenrudolf
May 10 2017 12:49
are there any examples of how I can use the ref property of a MuiTextField to manually set the focus on it? (I dont quite understand how to use the ref: MuiTextFieldM => Unit on a MuiTextField)
√ėyvind Raddum Berg
@oyvindberg
May 10 2017 18:12
@torstenrudolf the ref takes a function which gives you a reference to the mounted component. It doesn't feel that functional, but you can assign it to a var in the Backend.
class Backend {
  var ref: Option[MuiTextFieldM] = None
}

render() = {
  MuiTextField(ref = js.defined(c => ref = Some(c))
}

ref.foreach(_.focus())
TR
@torstenrudolf
May 10 2017 23:27
thx @oyvindberg ! was suspecting something like that but thought that can't be it :)