Skip to content

React 19 Compatibility: Remove defaultProps from Function Components #7518

@ggdouglas

Description

@ggdouglas

React 19 removes support for defaultProps on function components in favor of ES6 default parameters. As stated in the React 19 Upgrade Guide:

We're also removing defaultProps from function components in place of ES6 default parameters. Class components will continue to support defaultProps since there is no ES6 alternative.

Blueprint currently has two functional components that use the deprecated defaultProps object: DateInput and Overlay2

// TODO: Removing `defaultProps` here breaks tests. Investigate why.
// eslint-disable-next-line @typescript-eslint/no-deprecated
DateInput.defaultProps = DATEINPUT_DEFAULT_PROPS;

// eslint-disable-next-line @typescript-eslint/no-deprecated
Overlay2.defaultProps = OVERLAY2_DEFAULT_PROPS;

We will remove defaultProps from these components and replace with ES6 default parameters. The following PRs capture this:

Additionally, in the future when refactoring class components to function components, any instances of static defaultProps should also be replaced with ES6 default parameters.

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