Youssef
Youssef

Reputation: 110

Error when importing from semantic-ui-react

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.

Upvotes: 0

Views: 1839

Answers (2)

raj chakravarthy
raj chakravarthy

Reputation: 65

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 :)

Upvotes: 1

Abdelkarim EL AMEL
Abdelkarim EL AMEL

Reputation: 1533

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.

Upvotes: 1

Related Questions