subroh0508 / kotlin-material-ui

[UNMAINTAINED] Kotlin Wrapper Library of Material-UI
MIT License
74 stars 24 forks source link

Deprecate childWithStyles #14

Closed oxc closed 4 years ago

oxc commented 4 years ago

This pull request takes the changes from #12 one step further, by adding a final new variant of withStyles for function components, and deprecating childWithStyles and replacing it in all the samples.

Motivation: the childWithStyles variants always create a new component on each invocation, which prevents reconciliation of such components.

Instead, withStyles should be used to store the created higher order component in a RClass variable and call that to render the component.

This is also more similar to the original React API naming.

As a nice side-effect, this makes it much nicer to pass the styles directly to the withStyles function (see samples), which allows to omit the StyleSets.() -> Unit signature.