Skip to content

refactor(#2801): Remove defaultProps api for function components - #2812

Open
sbaechler wants to merge 2 commits into
reactstrap:masterfrom
ti8m:remove-default-props-api
Open

refactor(#2801): Remove defaultProps api for function components #2812
sbaechler wants to merge 2 commits into
reactstrap:masterfrom
ti8m:remove-default-props-api

Conversation

@sbaechler

Copy link
Copy Markdown
  • Bug fix
  • New feature
  • Chore
  • Breaking change
  • There is an open issue which this change addresses
  • I have read the CONTRIBUTING document.
  • My commits follow the Git Commit Guidelines
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • My change requires a change to Typescript typings.
    • I have updated the typings accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Fixes #2801

This pull request is based on #2806 by @islam-kamel.

The defaultProps were removed from the 3 functional components Fade, Tooltip and Popover.

It does require a new method that actively checks the props for undefined. Most likely because propTypes adds props that are not passed-in. However, the new method only does a shallow comparison (since functional components only do a shallow compare).

Comment thread src/Fade.js Outdated
@vladdg-dev

Copy link
Copy Markdown

Please remove defaultProps for all affected components. It's not only Fade, Tooltip and Popover. It's also Nav, NavItem, Badge, Breadcrumb, BreadcrumbItem, Container, Row, Col, Card, CardHeader, CardBody. Thank you.

@sbaechler

Copy link
Copy Markdown
Author

Please remove defaultProps for all affected components. It's not only Fade, Tooltip and Popover. It's also Nav, NavItem, Badge, Breadcrumb, BreadcrumbItem, Container, Row, Col, Card, CardHeader, CardBody. Thank you.

@vladdg-dev defautProps are only deprecated for function components. They are still supported for class components and all other components are class components.

@sbaechler
sbaechler force-pushed the remove-default-props-api branch from daea35f to ed2555e Compare August 7, 2024 14:15
@mizozobu

mizozobu commented Mar 8, 2025

Copy link
Copy Markdown

We need this. Some components are referencing Fade.defaultProps, but Fade.defaultProps is undefined.

I get the warning when I use Toast.

Warning: Failed prop type: The prop `timeout` is marked as required in `Fade`, but its value is `undefined`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants