problem in react route rendering while the component is in index.js

Viewed 18

this is the most simple route in react but it does'nt work and give this Error:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.


  
> 14 | render(<BrowserRouter><Switch><Route path='/' component={Simple}/></Switch></BrowserRouter>,document.getElementById('root'));
     |      ^

The code:

import React, { Component } from 'react';
import { render } from 'react-dom';
import { BrowserRouter,Switch,Route } from 'react-router-dom';
class Simple extends Component {
    constructor(props) {
        super(props);
    }
    state = {  }
    render() { 
        return ( <h1>g</h1> );
    }
}
 
render(<BrowserRouter><Switch><Route path='/' component={Simple}/></Switch></BrowserRouter>,document.getElementById('root'));
0 Answers
Related