Code snippets with material UI children not rendering correctly
See original GitHub issueDescribe the bug When I pass a MaterialUI component to a story as a child, it doesn’t generate the code snippet correctly
To Reproduce Import:
import Card from '@material-ui/core/Card';
Story:
import React from 'react';
// also exported from '@storybook/react' if you can deal with breaking changes in 6.1
import { Story, Meta } from '@storybook/react/types-6-0';
import Card from '@material-ui/core/Card';
import { Overlay, IProps } from './Overlay';
export default {
title: 'Display/Overlay',
component: Overlay,
argTypes: {},
parameters: {
docs: {
inlineStories: true,
}
},
} as Meta;
const Template: Story<IProps> = (args) => (
<Overlay {...args}>
<Card style={{ padding:'12px' }}>
Dummy Text
</Card>
</Overlay>
);
export const Basic = Template.bind({});
Basic.args = {};
Expected behavior
<Overlay>
<Card
style={{
padding: '16px'
}}
>
Dummy Text
</Card>
</Overlay>
Actual behavior
<Overlay>
<WithStyles(ForwardRef(Card))
style={{
padding: '16px'
}}
>
Dummy Text
</WithStyles(ForwardRef(Card))>
</Overlay>
System OS: macOS 11.0.1 CPU: (8) x64 Intel® Core™ i7-8557U CPU @ 1.70GHz Binaries: Node: 14.13.0 - /usr/local/bin/node Yarn: 1.22.5 - /usr/local/bin/yarn npm: 6.13.4 - /usr/local/bin/npm Browsers: Chrome: 87.0.4280.88 Firefox: 82.0.3 Safari: 14.0.1 npmPackages: @storybook/addon-actions: ^6.1.10 => 6.1.10 @storybook/addon-essentials: ^6.1.10 => 6.1.10 @storybook/addon-links: ^6.1.10 => 6.1.10 @storybook/node-logger: ^6.1.10 => 6.1.10 @storybook/preset-create-react-app: ^3.1.5 => 3.1.5 @storybook/react: ^6.1.10 => 6.1.10
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Material UI Stack first child component isn't indented correctly?
I think the problem is on the spacing=2, you can try to remove it, and then the indented will correct.
Read more >Troubleshooting - Material UI - MUI
First, check if you have configured the StyledEngineProvider correctly, as shown in the Style library section. If the StyledEngineProvider is already used at ......
Read more >Frequently Asked Questions - Material UI - MUI
My App doesn't render correctly on the server If it doesn't work, in 99% of cases it's a configuration issue. A missing property,...
Read more >Composition - Material UI - MUI
The custom component will be rendered by MUI like this: ... but the state will be lost, e.g. the ripple effect of the...
Read more >Style library interoperability - Material UI - MUI
There are examples for the following styling solutions: Plain CSS; Global CSS; Styled Components; CSS Modules; Emotion; Tailwind CSS; JSS TSS ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any news on this problem? In my perspective it doesn’t make sense to avoid the args parameter. Any ideas why it’s not working?
This is the documented behavior of the source block. see the
docs.source.type
parameter here: https://storybook.js.org/docs/react/writing-docs/doc-blocks#sourceI think the issue is that
<WithStyles(ForwardRef(IconButton)) color="inherit">
should render as<IconButton color="inherit" />
, which would be some kind of custom dynamic snippet rendering specifically for MUI. Given MUI’s popularity, I’d gladly accept a PR for that.