0

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'));
2

0

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.