0

I am trying to import elements from react semantic ui like this after installing via npm.

import React, { Component } from "react";
import "./App.css";
import { Button } from "semantic-ui-react";

    class App extends Component {
      render() {
        return <Button>hi</Button>;
      }
    }

    export default App;

enter image description here

But i get this error.

3
  • it seems that your error is not related to the App component, do you have other components in your app ? Commented Apr 6, 2019 at 18:54
  • No not yet, when I remove the import line of react Semantic it works fine. Commented Apr 6, 2019 at 19:02
  • check this stackblitz.com/edit/react-9xctbk Commented Apr 6, 2019 at 19:26

2 Answers 2

1

I guess the app was already running when you installed semantic-ui package, therefore, the appropriate file were not loaded.

Keep in mind to restart your app after installing every package or simply stop it before installing.

Sign up to request clarification or add additional context in comments.

Comments

1

There are two possible scenarios for this error:

1.Hot module reload not working: Sometimes the npm does not automatically reload the pages, so re-starting the app would solve this problem.

2.Yarn / NPM mismatch: Some packages (especially semantic-ui) throws error when there is a mismatch with package-json and yarn.lock. It is recommended to stick with yarn package manager if you are using yarn.

Hope this helps :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.