Hi I'm trying to pass props to a selected fragment...
# react
d
Hi I'm trying to pass props to a selected fragment and I don't know how to access it correctly. Any tips?
r
I’m not sure I’m familiar with the pattern you’re applying with the fragment, but if you’re looking to apply arbitrary props (props that aren’t represented by a Kotlin type extending Props), you have do something like:
Copy code
selected.create {
  asDynamic()["text-fill-color"] = "initial"
}
though i think you’d probably be better off making real types to avoid all that
if the type you’d get from that “getOrElse” has those properties enumerated, you could “unsafe cast” that Fragment to that type. As a type-safety-enjoyer I think you’d probably be better off using “getOrNull” and then use an elvis to create the fragment
Copy code
selected?.create {
  esgState = props.esgState
...
} ?: Fragment.create()
or some other variation that doesn’t require you to pretend the fragment cares about something it won’t use