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

Specific Webpack Loader is Required for React? #14

Closed
adrianmcli opened this issue Apr 1, 2016 · 6 comments
Closed

Specific Webpack Loader is Required for React? #14

adrianmcli opened this issue Apr 1, 2016 · 6 comments

Comments

@adrianmcli
Copy link

I'm trying to use storybook for an existing component in my Mantra app. The ChatInput.jsx component has two import statements at the top for React and the PureRenderMixin. I had assumed that storybook would work out of the box with Mantra apps. Do I need to do some webpack configuration in order to load my component?

This is the error I get from the storybook GUI:

My First Button
ERROR in ./client/modules/chat/components/ChatInput.jsx
Module parse failed: /Users/adrianmc/dev/olis-mantra/client/modules/chat/components/ChatInput.jsx Line 1: Unexpected token
You may need an appropriate loader to handle this file type.
| import React from 'react';
| import PureRenderMixin from 'react-addons-pure-render-mixin';
| 
 @ ./.stories/chatInput.js 9:17-75

This is the story file:

import React from 'react';
import { storiesOf, action } from '@kadira/storybook';

import ChatInput from '../client/modules/chat/components/ChatInput.jsx';

storiesOf('ChatInput', module)
  .add('simple', () => (
    <ChatInput />
  ));
@arunoda
Copy link
Member

arunoda commented Apr 1, 2016

Just rename you module to ChatInput.js and it'll work.

@adrianmcli
Copy link
Author

@arunoda Thanks! You may close this.

@arunoda
Copy link
Member

arunoda commented Apr 1, 2016

Great.

@arunoda arunoda closed this as completed Apr 1, 2016
@kevinSuttle
Copy link
Contributor

kevinSuttle commented Sep 29, 2016

Seeing the same issue locally, but not using a .jsx file extension.

It's specifically calling out line 42: https://gist.github.com/arunoda/fb3859840ff616cc5ea0fa3ef8e3f358#file-register-js-L42

<div style={styles.notesPanel}>

I used the guide and gist from here: https://getstorybook.io/docs/addons/writing-addons

I tried putting the root .babelrc in .storybook. No dice.
https://getstorybook.io/docs/configurations/custom-babel-config

@kevinSuttle
Copy link
Contributor

kevinSuttle commented Sep 29, 2016

There seems to be a lot of info missing from the docs, like adding babel etc, and specifying a dist folder.

https://github.com/kadirahq/storybook-addon-notes/blob/master/register.js
https://github.com/kadirahq/storybook-addon-notes/blob/master/package.json#L53

Or that you need: .storybook/config.js and .storybook/stories.js

@kevinSuttle
Copy link
Contributor

I have a working implementation here: https://cloudup.com/cwK7EtZCpaw

ndelangen pushed a commit that referenced this issue Apr 5, 2017
Do not import addons.js on entryfiles
ndelangen pushed a commit that referenced this issue Apr 5, 2017
ndelangen pushed a commit that referenced this issue Apr 5, 2017
Pass the returned value to module caller
ndelangen pushed a commit that referenced this issue Apr 5, 2017
Display prop values of type function and React element
ndelangen added a commit that referenced this issue Apr 5, 2017
ndelangen pushed a commit that referenced this issue Apr 11, 2017
Increase comment font size #9
ndelangen pushed a commit that referenced this issue Apr 11, 2017
ndelangen pushed a commit that referenced this issue May 11, 2017
…20.1

@kadira/storybook@2.20.1 untested ⚠️
thani-sh pushed a commit that referenced this issue May 24, 2017
New, static site starting from Gatsby starter kit
ndelangen pushed a commit that referenced this issue Apr 16, 2019
leoyli pushed a commit that referenced this issue Apr 17, 2019
leoyli pushed a commit that referenced this issue Apr 17, 2019
leoyli pushed a commit that referenced this issue Apr 18, 2019
leoyli pushed a commit that referenced this issue Apr 18, 2019
leoyli pushed a commit that referenced this issue Apr 18, 2019
leoyli pushed a commit that referenced this issue Apr 18, 2019
leoyli pushed a commit that referenced this issue Apr 18, 2019
leoyli pushed a commit that referenced this issue Apr 18, 2019
leoyli pushed a commit that referenced this issue Apr 18, 2019
leoyli pushed a commit that referenced this issue Apr 18, 2019
leoyli pushed a commit that referenced this issue Apr 18, 2019
leoyli pushed a commit that referenced this issue Apr 18, 2019
leoyli pushed a commit that referenced this issue Apr 18, 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

3 participants