0

I am new to react. I am getting an error ( Module not found: Can't resolve 'react-lodable' ) while doing routing in my react app.

Here is my code:

route.js:

import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import React, { Component } from 'react';
import Loadable from 'react-loadable';
import './App.css';

const Loading = () => <div> Loading... </div>;

const Home=Loadable({
    loader:()=>import('./components/home-component/Home'),
    loading:Loading
});

const User=Loadable({
    loader:()=>import('./components/user-component/User'),
    loading:Loading

});

class App extends Component {
  render() {
    return (
      <Router>
      <Switch>
          <Route exact path="/" component="Home" />
          <Route path="/user" component="User" />
      </Switch>
  </Router>
    );
  }
}

export default App;
Shubham Verma
  • 8,783
  • 6
  • 58
  • 79

3 Answers3

0

As per your code you are doing it right but error says Module not found: Can't resolve 'react-lodable' so some where you are misspelling it as react-lodable instead of react-loadable

aravind_reddy
  • 5,236
  • 4
  • 23
  • 39
0

I also got the same issue, when I deleted my node modules and did yarn install or npm install it worked.

Aphrem Thomas
  • 263
  • 2
  • 8
0

I also got the same issue too, I found that react-loadable did not exist in my package.json, then tried npm install react-loadable

Mohammad Reza
  • 693
  • 9
  • 16