iTwin / iTwinUI-react

A react component library for iTwinUI.
https://github.com/iTwin/iTwinUI
Other
83 stars 23 forks source link

fix(ThemeProvider): Exclude `ownerDocument` from `themeOptions` if children passed #973

Closed mayank99 closed 1 year ago

mayank99 commented 1 year ago

Instead of relying on UseThemeProps, ThemeProvider now defines its own props and uses conditional typing to exclude ownerDocument from themeOptions if children is passed, and keep ownerDocument if children not passed (for backwards compatibility). This change is intended to prevent accidentally passing ownerDocument. Would be nice to release it as a patch of 2.0 rather than in 2.1 so that users have a smaller window to make this mistake.

Also, since we are defining a new type, I used the opportunity to write a better jsdoc for the theme prop, warning about SSR behavior.

mayank99 commented 1 year ago

It would be nice to have tests for these scenarios to make sure we don't break it in the future.

This is all typescript stuff and there is no change in runtime, so I'm not really sure how to test it tbh.

gretanausedaite commented 1 year ago

This is all typescript stuff and there is no change in runtime, so I'm not really sure how to test it tbh.

Add examples with different usage might be a start [Another PR problems]