looker-open-source / components

Looker's UI Components, Design Infrastructure and more
https://components.looker.com
MIT License
62 stars 31 forks source link

React 18+ Providers error when FC is using children #2975

Closed taystack closed 1 year ago

taystack commented 1 year ago
package version
typescript 4.9.4
react 18.2.0
@looker/components 4.0.4

I am getting a typescript error when using the <ComponentsProvider>:

Type '{ children: Element }' has no properties in common with type 'IntrinsicAttributes & ComponentsProviderProps'

See here: Screen Shot 2023-01-05 at 11 57 18 AM

Fix: I personally ran into this problem when upgrading to react 18. FC properties no longer expect children, so custom properties need to be more explicit:

export interface ComponentsProviderProps extends ThemeProviderProps, ExtendComponentsTheme, UseI18nProps {
  // ...
}

// Should extend an additional React.PropsWithChildren<{}> type:
export interface ComponentsProviderProps extends ThemeProviderProps, ExtendComponentsTheme, UseI18nProps, React.PropsWithChidlren<{}> {
  // ...
}

I can make a PR for this if that helps.

taystack commented 1 year ago

I made a PR https://github.com/looker-open-source/components/pull/2976

Hopefully this change doesn't break anything - it shouldn't but I had troubles with development.

Thanks ya'll.

elliot-at-looker commented 1 year ago

This is being tracked internally with ticket 255844186

guyellis commented 1 year ago

@taystack we are actively working on a change to address this in our internal code base. Once complete we'll release a fix. Thanks.

mdodgelooker commented 1 year ago

@taystack this issue is resolved in v4.1.1.

guyellis commented 1 year ago

@taystack did this resolve your issue?

taystack commented 1 year ago

@guyellis, @mdodgelooker I've verified this works on React18 without any typescript issues. 🌮 thanks for this!