These are chat archives for riot/riot

Dec 2016
Dec 03 2016 12:29

Good Day guys, why my


return undefined

Tsutomu Kawamura
Dec 03 2016 13:22
this.on('mount', () => { console.log(this.ref) })
Vyacheslav Moskalev
Dec 03 2016 17:15
hey guys. just tinkering with riot server-side rendering. and got a problem I need that on('mount') the input will focus on the client, but on server that causes an error because focus() is not a function :( How to check if that's server-side or not. Is there any standard ways to go?
btw this.refs gets the input but of course it cannot be focused server-side.
@jklesmes17 as I understand this.refs becomes available only after mount. so @cognitom is right but has a typo: this.ref
Vyacheslav Moskalev
Dec 03 2016 17:34
Made it this way. Passing clientSide var on client with riot.mount('*', { clientSide: true }). But it looks ugly.
this.on('mount', function() {
  this.input = this.refs.firstName

  if (opts.clientSide) {
If someone has a better solution tell me please. Thank you.
Just want my components to be free from that logic. I think that's not their business.
Vyacheslav Moskalev
Dec 03 2016 17:48
Another way:
let input

this.on('mount', function() {
  input = this.refs.firstName
  input.focus ? input.focus() : null
Dec 03 2016 19:22
@jklesmes17 did you actually create any? like <input ref="name" ... ? in you tag
Vyacheslav Moskalev
Dec 03 2016 22:34
@Dreamvention must be [] then, or not?