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.

CSS error given when index.css is used in tutorial

See original GitHub issue

There appears to be a problem with the CSS of the Learn Storybook tutorial.

Following the instructions exactly up to and including the Config section of https://www.learnstorybook.com/intro-to-storybook/react/en/simple-component/ gives the following error:

image

I can fix this by commenting out the relevant piece of CSS in index.css as follows but then the rendering of the icons is not correct.

image

This error may put beginner users off, so any resolution would be much appreciated.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:9

github_iconTop GitHub Comments

6reactions
jonniebigodescommented, Oct 27, 2020

@nsclong sorry for the issue you are facing with the tutorial. I took a look and it seems it might be related to the recent update to react-scripts and react as part of the create-react-app package. As of now when you follow the instructions detailed in the tutorial, your package.json will look like this:

{
  "name": "taskbox",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-scripts": "4.0.0",
    "web-vitals": "^0.2.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "storybook": "start-storybook -p 6006 -s public",
    "build-storybook": "build-storybook -s public"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@babel/core": "^7.12.3",
    "@storybook/addon-actions": "^6.0.27",
    "@storybook/addon-essentials": "^6.0.27",
    "@storybook/addon-links": "^6.0.27",
    "@storybook/node-logger": "^6.0.27",
    "@storybook/preset-create-react-app": "^3.1.4",
    "@storybook/react": "^6.0.27",
    "babel-loader": "^8.1.0",
    "react-is": "^17.0.1"
  }
}

If you continue to follow the instructions provided up to the Simple component page you’ll run into the error you mentioned.

As a temporary workaround you could do the following:

  • Delete node_modules and yarn.lock/ package.lock.
  • Change react-scripts to a previous version, you can use 3.43.
  • Change react and react-dom to a previous version. You can use version 16.3.1

Which will result in your package.json to look like:

{
  "name": "taskbox",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.3",
    "web-vitals": "^0.2.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "storybook": "start-storybook -p 6006 -s public",
    "build-storybook": "build-storybook -s public"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@babel/core": "^7.12.3",
    "@storybook/addon-actions": "^6.0.27",
    "@storybook/addon-essentials": "^6.0.27",
    "@storybook/addon-links": "^6.0.27",
    "@storybook/node-logger": "^6.0.27",
    "@storybook/preset-create-react-app": "^3.1.4",
    "@storybook/react": "^6.0.27",
    "babel-loader": "^8.1.0",
    "react-is": "^17.0.1"
  }
}

And once you issue yarn storybook the development build will go through as you can see below:

working-intro-storybook-cli

And your Storybook will load without issues:

working-intro-storybook-ui

I’ve checked with the Storybook maintainers and they are actively working on fixing this issue and provide the exact seamless integration that you and the other readers of the tutorial had in the past.

If you want to keep track on the progress being done. Check the Storybook Discord server and repo.

Stay safe

1reaction
jonniebigodescommented, Nov 19, 2020

@nicc777 React 17 and CRA were updated recently and that introduced some changes that were tracked and should now be fixed. Also Storybook just released 6.1 and it should take care of some of the issues that the tutorial has been suffering. I’m currently working on checking the tutorial and see what needs to be changed.

Stay safe.

Read more comments on GitHub >

github_iconTop Results From Across the Web

z-index - CSS: Cascading Style Sheets - MDN Web Docs
The z-index CSS property sets the z-order of a positioned element and its descendants or flex items. Overlapping elements with a larger ...
Read more >
CSS Z-Index Not Working? How to Fix It Using Stack Order
The z-index property of CSS is a tricky one. It won't work easily by itself if you don't know how to use it...
Read more >
How to Troubleshoot CSS Not Working
In this tutorial, we'll walk through options to troubleshoot why your CSS is not working and offer possible solutions. Browser Caching.
Read more >
Webpack: node_modules/css/index.js didn't return a function
This error is caused by a css module inside node_modules . Since you've specified the css -loader in your config, webpack tries to...
Read more >
CSS z-index property
... Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, ... The z-index property specifies the stack...
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