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.

[Material-UI v5 alpha 32] experimentalStyled missing styleProps in typescript definition

See original GitHub issue

Trying to create my own component using experimentalStyled mimicking Autocomplete in typescript I got a compile error on styleProps property

<AutocompleteLoading styleProps={props}>
  This is not compiling
</AutocompleteLoading>

Property ‘styleProps’ does not exist on type …

In Sandbox a simplified example https://codesandbox.io/s/interesting-babbage-zyrpz?file=/src/Demo.tsx:658-757

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
david-ic3commented, May 2, 2021

Thanks for the quick turnaround, I see I’m not the only one working on week-ends, guys really no need.

From a documentation side a bit around this experimentalStyle function would be welcomed as an example on how to create a composed component like an MUI one from scratch.

To get a hint what we are trying to achieve (selected is a new prop) :

function MyUselessButton(props: PropsOf<typeof Button> & {selected: boolean | undefined} ) {
    return <Button {...props} />;
}

const FilterButton = experimentalStyled(MyUselessButton, {
    shouldForwardProp: (prop) => prop !== 'selected',
})(({selected, theme}) => ({
    ...theme.components!['FilterButtons'].styleOverrides.muiButton,   // it's a bit of hack and we don't have variants
    ...selected && {backgoundColor: theme.live['selection'].selectedColor}
}));

my one cent

1reaction
oliviertassinaricommented, May 1, 2021

Could it be seen as a duplicate of #24862?

Spreading extra props might actually be something we could document in https://next--material-ui.netlify.app/guides/styled-engine/ (in addition to the existing customization page). We currently cover it in https://next--material-ui.netlify.app/customization/how-to-customize/#dynamic-css.

Read more comments on GitHub >

github_iconTop Results From Across the Web

material-ui-docs/CHANGELOG.md at latest · mui ... - GitHub
This is a breaking change for anyone who depends on the class names applied to Base components. If you use the <component>UnstyledClasses objects,...
Read more >
TypeScript - Material UI - MUI
Have a look at the Create React App with TypeScript example. ... Use the styled() utility in order to customize the styles of...
Read more >
mui/material/CHANGELOG.md - UNPKG
- The `jssPreset` object is no longer exported from `@material-ui/core/styles`. You should import it directly from `@material-ui/styles`.
Read more >
Material-UI v5 not working styled-components and typescript?
when doing: import { ThemeProvider } from "@mui/material/styles";. I made a Code Sandbox to show my setup. Does anyone know what I'm doing...
Read more >
node_modules/@material-ui/styles/CHANGELOG.md - GitLab
A new fontWeightBold typography theme value (#16036) @aditya1906. Reduce TypeScript compile time when using the icons (#16083) @phryneas. And many more ...
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