question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Badge] v4 deprecation warnings in default Badge usage

See original GitHub issue

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

In the 4.12.4 release of @material-ui/core, the Badge component started giving the following warning in its default configuration:

Warning: Failed prop type: Material-UI: overlap="rectangle" was deprecated. Use overlap="rectangular" instead.

Expected behavior 🤔

Badge should be usable in its default configuration without errors.

Steps to reproduce 🕹

Steps:

  1. Visit https://codesandbox.io/s/mui-badge-deprecation-b9n498?file=/src/App.tsx
  2. Note the deprecation warning in the console.

Context 🔦

This is apparently the result of #27573. If I understand correctly, that was to address the problem of updating classes but not overlap - however, getting an error on the default configuration seems like a step backwards. (I’m assuming that overriding the classes key is done less frequently.)

As a suggested fix, what about reverting this line and extending the deprecatedClassKey logic to communicate the issue with default overlap there?

    [
      'anchorOriginTopRight',
      'anchorOriginBottomRight',
      'anchorOriginTopLeft',
      'anchorOriginBottomLeft',
    ].forEach(([classKey]) => {
      [
        ['rectangle', 'rectangular'],
        ['circle', 'circular'],
      ].forEach(([deprecatedOverlap, newOverlap]) => {
        const deprecatedClassKey = classKey + deprecatedOverlap;
        if (
          classes[deprecatedClassKey] != null &&
          // 2 classnames? one from withStyles the other must be custom
          classes[deprecatedClassKey].split(' ').length > 1
        ) {
          const newClassKey = classKey + newOverlap;
          throw new Error(
            `Material-UI: The \`${deprecatedClassKey}\` class was deprecated. Use \`${newClassKey}\` instead (and make sure that \`overlap=${newOverlap}\`).`,
          );
        }
      });
    });

I can submit a PR for this if it seems reasonable.

Your environment 🌎

`npx @mui/envinfo` Using Chrome
  System:
    OS: macOS 12.3
  Binaries:
    Node: 14.19.1 - ~/.nvm/versions/node/v14.19.1/bin/node
    Yarn: 1.22.18 - /opt/homebrew/bin/yarn
    npm: 6.14.16 - ~/.nvm/versions/node/v14.19.1/bin/npm
  Browsers:
    Chrome: 99.0.4844.84
    Edge: Not Found
    Firefox: 98.0.2
    Safari: 15.4

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:16
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

20reactions
DDukerscommented, Jun 1, 2022

I resolved this by specifying the overlap=“rectangular” prop everywhere where i used the Badge-components in my code. If you don’t supply this property it reverts to the specified default value which is set to "overlap=“rectangle”.

When deprecating prop values used as default it would be nice if those defaults would be updated to the new value.

3reactions
simplecommercecommented, Jun 1, 2022

I resolved this by specifying the overlap=“rectangular” prop everywhere where i used the Badge-components in my code. If you don’t supply this property it reverts to the specified default value which is set to "overlap=“rectangle”.

When deprecating prop values used as default it would be nice if those defaults would be updated to the new value.

I did the same, since I am using themes, I specified it in the default props. I didn’t think of that until I read your post, thanks!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Usage of the lifecycle package
Find out what deprecated features you rely on​​ Forcing warnings can be useful in conjuction with last_warnings() , which prints backtraces for all...
Read more >
Badge API - Material UI
It's recommended to use the slotProps prop instead, as componentsProps will be deprecated in the future. If true , the badge is invisible....
Read more >
Badge - Forma 36
badges are used to inform users of the status of an element in the interface; keep in mind the recommended color coding for...
Read more >
Badges - GitLab Docs
Use custom badge images in a project or a group if you want to use badges other than the default ones. Prerequisites: A...
Read more >
Deprecation Warning in Bootstrap SCSS
You can downgrade your version to stop the warnings for now and doing so shouldn't break anything either. tl:dr You should use Sass:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found