Hi, i updated my project recently to kotlin 1.5 bu...
# javascript
k
Hi, i updated my project recently to kotlin 1.5 but I am now having issues with the
react-dom
library. I can't set the
ref
attribute for my react components, since it no longer allows passing lambdas to
attrs.ref
.
Copy code
var myRef : Element? = null

styledDiv {
  attrs.ref {
    myRef = it as? Element
  }
}
So the above code no longer works. Is there a workaround for this?
1
t
Copy code
var myRef : Element? = null

styledDiv {
  attrs.ref = RefCallback<Element> {
    myRef = it
  }
}
Via
useRefState
Copy code
val (element, elementRef) = useRefState()

styledDiv {
  attrs.ref = elementRef
}
K 2
k
🙏