facebook / relay

Relay is a JavaScript framework for building data-driven React applications.
https://relay.dev
MIT License
18.42k stars 1.83k forks source link

TS2786: 'RelayEnvironmentProvider' cannot be used as a JSX component. #4598

Open kawazoe opened 10 months ago

kawazoe commented 10 months ago

The typescript types for RelayEnvironementProvider doesn't appear to be compatible with @types/react@18.2.48. React did some changes to how JSX element types are declared last year and recommended to use ReactNode instead of JSX.Element or ReactElement.

Trying to update to the latest version of react's types causes components that uses RelayEnviornementProvider to stop compiling with the following error:

TS2786: RelayEnvironmentProvider cannot be used as a JSX component.
  Its type
    (props: Props) => ReactElement<ProviderProps<RelayContext>, string | JSXElementConstructor<any>>
  is not a valid JSX element type.
    Type
      (props: Props) => ReactElement<ProviderProps<RelayContext>, string | JSXElementConstructor<any>>
    is not assignable to type
      (props: any, deprecatedLegacyContext?: any) => ReactNode
      Type
         ReactElement<ProviderProps<RelayContext>, string | JSXElementConstructor<any>>
      is not assignable to type ReactNode
        Property children is missing in type
          ReactElement<ProviderProps<RelayContext>, string | JSXElementConstructor<any>>
        but required in type ReactPortal

I didn't provide a specific repro project as I feel this error is self explaining. I tried the glitch link but the react and relay version that are installed is very old. It's also trivial to take any existing up-to-date react project which should use RelayEnvironementProvider and install the correct version of react's types.

dyakubovsky-da commented 9 months ago

Same for me

adstr123 commented 1 month ago

Still the case for me too.

mortezaalizadeh commented 1 month ago

same here, but it is happening since I tried using react 19-rc in my nextjs app. Main reason I am trying to use release candidate is I wanna jump on Nextjs 15 that is just released