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.

Using Storybook with MobX and CRA

See original GitHub issue

I’m having trouble running Storybook with MobX, i’m using create-react-app with react-app-rewired.

Here’s my babel configuration in package.json

    "plugins": [
      [
        "@babel/plugin-proposal-decorators",
        {
          "legacy": true
        }
      ]
    ],

Storybook config .storybook/config.js

import { configure } from '@storybook/react';

configure(require.context('../src', true, /\.stories\.js$/), module);

react-app-rewire configuration config-overrides.js

const {
    override,
    disableEsLint,
    addDecoratorsLegacy,
    fixBabelImports,
} = require("customize-cra");
module.exports = override(
    disableEsLint(),
    addDecoratorsLegacy(),
    fixBabelImports("react-app-rewire-mobx", {
        libraryDirectory: "",
        camel2DashComponentName: false
    }),
);

I get the following error when i run yarn run storybook :

…src\store\KeyframesStore.js: Support for the experimental syntax ‘decorators-legacy’ isn’t currently enabled (6:5):

image

The app works fine with current config, is there any missing configuration for storybook ?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
mrmckebcommented, Jan 17, 2020

Hi @SaadRegal, I can confirm this work fine with @storybook/preset-create-react-app.

All I did was add a main.js with:

module.exports = {
  addons: ["@storybook/preset-create-react-app"]
};

I then saw another error, which was related to an import of a non-existent file (a jpg). I removed that, and everything worked as expected.

Let me know how you go with this 😃

2reactions
shilmancommented, Dec 16, 2019

You need to use the standalone preset @storybook/preset-create-react-app (if you’re not already) and configure it to use react-app-rewired.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Using Storybook with MobX and CRA - - Bountysource
I'm having trouble running Storybook with MobX, i'm using create-react-app with react-app-rewired. Here's my babel configuration in package.json
Read more >
Wire in data - Storybook Tutorials
To get data into it, we need a “container”. This example uses Redux, the most popular React library for storing data, to build...
Read more >
Discussion of How to: mobx-state-tree + react + typescript
This is a walkthrough on how to get a full setup with mobx-state-tree and react in a CRA app with typescript. This guide...
Read more >
mobx-book-store-example - CodeSandbox
CodeSandbox is an online editor tailored for web applications.
Read more >
MobX 6 has been released (decorator free and supports CRA ...
131 votes, 24 comments. 330K subscribers in the reactjs community. A community for learning and developing web applications using React by ...
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