Skip to content

TS Error: SnackbarProvider cannot be used as a JSX component #485

@ryancrunchi

Description

@ryancrunchi

Seems there is a conflict in types between @types versions used. I use "@types/react": "^18.0.8" and "@types/react-dom": "^18.0.0" while notistack and/or mui use "@types/react": "^16.8.6 || ^17.0.0" or "@types/react": "^16.9.23"

Expected Behavior

No compiler error

Current Behavior

Compiler error:

'SnackbarProvider' cannot be used as a JSX component.
  Its instance type 'SnackbarProvider' is not a valid JSX element.
    The types returned by 'render()' are incompatible between these types.
      Type 'React.ReactNode' is not assignable to type 'import("node_modules/@mui/types/node_modules/@types/react/index").ReactNode'.
        Type '{}' is not assignable to type 'ReactNode'.
          Type '{}' is missing the following properties from type 'ReactPortal': key, children, type, props

Steps to Reproduce

Link:

Context

Your Environment

Tech Version
Notistack v2.0.4
React ^18.1.0
@types/react ^18.0.8
@types/react-dom ^18.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions