Skip to content

Incorrect type definition for React elements #14064

@sbly

Description

@sbly

According to the official site, React components may return null to prevent any rendering. But due to a likely bug in the definition files, I get a type error when trying to use a component that possibly returns null. Here is the compiler error:

    (54,3): error TS2345: Argument of type '(props: PaginationProps) => Element | null' is not assignable to parameter of type 'ComponentClass<PaginationProps & {}> | StatelessComponent<PaginationProps & {}>'.
      Type '(props: PaginationProps) => Element | null' is not assignable to type 'StatelessComponent<PaginationProps & {}>'.
        Type 'Element | null' is not assignable to type 'ReactElement<any>'.
          Type 'null' is not assignable to type 'ReactElement<any>'.

I think the fix is to make ReactElement nullable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions