Hi, what is the Kotlin idiomatic way to translate javascript spread operator as used in React to spread props in a component ?
✅ 1
m
Moritz Hofmeister
05/15/2023, 11:38 AM
Object.assign(this, params)
or
+params
🙌 1
f
Francesco Pasqualini
05/15/2023, 1:49 PM
thanks, in order to use "+params" do I need to implement the React.props interface ?
m
Moritz Hofmeister
05/16/2023, 8:13 AM
Yes, the
+
is an operator override on the react props interface 🙂
🙌 1
Moritz Hofmeister
05/16/2023, 8:14 AM
This is an example on how we use it with an MUI
Autocomplete
component
🙌 1
f
Francesco Pasqualini
05/16/2023, 8:36 AM
ok.. perfect
I have developed a small library to use ReactHookForm and MUI components in kotlinjs
thank to you now I've added +field.props syntax sugar :-)