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.

Setting disableRipple on ListItem customization theme will throw a Typescript error

See original GitHub issue

Hi! I am trying to disable the ripple effect globally on a ListItem that uses a Button as a list item, through the createMuiTheme.props. I’m using React, Typescript, and Material UI.

createMuiTheme({
  props: {
    MuiListItem: {
      disableRipple: true,
      disableTouchRipple: true
    }
  }
})

Typescript will throw the following error:

Types of property ‘MuiListItem’ are incompatible. Type ‘{ disableRipple: boolean; disableTouchRipple: boolean; disableFocusRibble: boolean; }’ has no properties in common with type ‘Partial<OverrideProps<ListItemTypeMap<{}, “li”>, “li”>>’.ts(2322)

What is the proper way to set this up?

Here is a code sandbox showing the type error: ~https://codesandbox.io/s/using-buttonbase-props-in-muilistitem-default-props-v7fjb?file=/src/App.tsx~ https://codesandbox.io/s/using-buttonbase-props-in-muilistitem-default-props-forked-6jdnx

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ryancogswellcommented, Dec 13, 2020

@eps1lon I’ve added a sandbox and removed the one invalid prop (disableFocusRipple) from the initial issue text. The gist of the problem is that Typescript complains when specifying ButtonBase props within the MuiListItem portion of the theme props.

Here’s the related StackOverflow question (presumably from the same person): https://stackoverflow.com/questions/65274453/overwrite-material-ui-prop-types.

0reactions
eps1loncommented, Dec 13, 2020

but ButtonBase props are part of the ListItem API when the button prop is used;

So are any other props for a specific component. It sounds like a niche case and considering the first time I see it, TypeScript actually prevented a mistake, it’s probably safer to let people trip over it first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve typescript errors in custom theme in Material UI ...
But we are getting typescript error due to custom properties as following picture. Is it any way to define the type for custom...
Read more >
Changing list component's disableRipple input does ... - GitHub
Setting disableRipple input of mat-nav-list or mat-action-list should prevent child mat-list-item 's from having a ripple effect when they ...
Read more >
mui/material/CHANGELOG.md - UNPKG
13 -->[Avatar] Fix TypeScript error on imgProps (#30255) @ahmad-reza619 ... 580, - [IconButton] Remove on hover effect when `disableRipple` is set (#29298) ...
Read more >
@material/mwc-list | Yarn - Package Manager
Fixed bug where setting the <mwc-snackbar> labelText property could throw an exception and fail to render (#412). Buttons slotted into <mwc-snackbar> now render ......
Read more >
Design Patterns with React Easy State | by Bertalan Miklos
If set to 0 (default) a\\n * timeout is not created. ... errors are hidden from us by the browser\\n \u002F\u002F onerror should...
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