Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not woking with @storybook/react 4.1.4 #90

Closed
SokolovAlex opened this issue Dec 27, 2018 · 10 comments
Closed

not woking with @storybook/react 4.1.4 #90

SokolovAlex opened this issue Dec 27, 2018 · 10 comments

Comments

@SokolovAlex
Copy link

SokolovAlex commented Dec 27, 2018

create simple storybook project from
https://storybook.js.org/basics/guide-react/

/// package.json
{
"scripts": {
"storybook": "start-storybook -p 9001 -c .storybook"
},
"devDependencies": {
"@storybook/react": "^4.1.4"
},
"dependencies": {
"@babel/core": "^7.2.2",
"babel-loader": "^8.0.4",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"storybook-addon-material-ui": "^0.8.11"
}
}

/// .storybook/config.js
import { configure } from '@storybook/react';

function loadStories() {
require('../stories/index.js');
// You can require as many stories as you need.
}
configure(loadStories, module);

add addon
import 'storybook-addon-material-ui/register';

after that storybook cant starting
image

what did i do wrong?

@usulpro
Copy link
Member

usulpro commented Dec 27, 2018

Hi
You need to use the "storybook-addon-material-ui@0.9.0-alpha.16. It's the latest version

@SokolovAlex
Copy link
Author

I try both
"storybook-addon-material-ui": "^0.9.0-alpha.16"
and
"storybook-addon-material-ui": "^0.8.11"

same result

@usulpro
Copy link
Member

usulpro commented Dec 27, 2018

@SokolovAlex Ok, I'll check it, thanks for reporting this

@usulpro
Copy link
Member

usulpro commented Dec 29, 2018

note to myself storybookjs/storybook#4995

@usulpro
Copy link
Member

usulpro commented Dec 29, 2018

@SokolovAlex At this moment the best workaround is to downgrade Storybook to v4.0.9

you can check out https://github.com/react-theming/create-material-ui-app with working dependencies

@alistair-hmh
Copy link

alistair-hmh commented Jan 22, 2019

@usulpro - just out of interest? Why does material ui register break with the new Storybook React?

The frustrating thing here is that I can't use @storybook/react@v4.0.9 because my app was created with create-react-app@2.1.1 - which no longer uses webpack.config.dev in react-scripts.

@usulpro usulpro pinned this issue Jan 23, 2019
@usulpro
Copy link
Member

usulpro commented Jan 26, 2019

Hi @alistair-hmh
I didn't dig but looks like it transpiles into something incompatible. Possible Babel updating would help. Here is a working example https://github.com/storybooks/addon-development-kit/tree/version-1

@SKCrawford
Copy link

SKCrawford commented Mar 3, 2019

Has any progress been made towards resolving this issue? I cannot downgrade storybook because of create-react-app. Otherwise, is there any other (simple) way to provide the theme manually?

Edit: I've answered my own question. For anyone using material-ui@next (currently 4.0.0-alpha.1), wrap the targeted component like so:

import { ThemeProvider } from '@material-ui/styles';

import { theme } from './wherever';

storiesOf('Component', module)
  .addDecorator(story => (
    <ThemeProvider theme={theme}>{story()}</ThemeProvider>
  ))      
  .add('default', () => <Component /* prop stuff */ />)
  .add('', () => <></>);

For the stable branch, I believe it's still appropriate to use MuiThemeProvider from @material-ui/core. I was using the wrong provider, which disguised my issue.

@SleepWalker
Copy link

This may be due to add-on, because starting from 4.1.x you can not import any core node modules in addons. This will lead to compile error, but due to storybookjs/storybook#5584 it will hang without showing error.
You can apply patch manually simply to see an actual error, or try to test with storybook 5, where the bug with hidden errors is fixed

@usulpro
Copy link
Member

usulpro commented Apr 14, 2019

Solved in #92

@usulpro usulpro closed this as completed Apr 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants