Skip to content

Type of usePrevious is not entirely correct #323

Open
@FleetAdmiralJakob

Description

The type of usePrevious:

export function usePrevious<T>(newValue: T): T;

And should be updated to:

  export function usePrevious<T>(newValue: T): T | null;

as the previous state here can be null:

usehooks/index.js

Line 1019 in 90fbbb4

const [previous, setPrevious] = React.useState(null);

Potentially related issues: #275, #316

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