Now that the wrapper child functions don't return ...
# react
c
Now that the wrapper child functions don't return a ReactElement, what is the best way to get and assign a ReactElement, for example, given this js:
Copy code
renderOption={(option) => (
        <React.Fragment>
          <span>
            {option.label}
          </span>
        </React.Fragment>
      )}
In my Kotlin code, it used to be like this:
Copy code
renderOption = { option, _ ->
    Fragment {
        span {
            +option.label
        }
    }
}
What is the recommended way of doing this now?
t
Previously parent builder was abused (bad practice) And now and previously following recommended:
Copy code
renderOption = { option, _ ->
    buildElement {
        span {
            +option.label
        }
    }
}
c
Thanks very much, yes, I have not really known what the good practices are, at least this makes the bad practice not compile 🙂. Thanks again!
t
Previously your element was child of 2 parents
1 parent - current in context
Fragment
called on builder 2 parent - your component
If your component will not use child you will see it in parent 1 🙂
c
Yes, I have come accros such things and used (I imagine) other bad practices to solve them... e.g. a local RBuilder 🙂
t
buildElement
create element, but don’t attach it to parent - you will do it in your component
For elegant solutions some redundant limitations must be removed
And muti contexts :)
c
Thanks for that, I will have a read 🙂
t