here is my index.js file
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-dom'
import App from './components/App';
ReactDOM.render((
<BrowserRouter>
<App />
</BrowserRouter>
), document.getElementById('root')
);
and this is App.js
import React, { Component } from 'react';
import Main from './Main';
class App extends Component {
render() {
return (
<div>
<Main />
</div>
);
}
}
export default App;
and this is my Main.js file
import React, { Component } from 'react';
import { Switch, Route } from 'react-router-dom';
import Home from './Home';
import AdminHome from './AdminHome';
class Main extends Component {
render() {
return (
<Switch>
<Route exact path='/admin' component={AdminHome}/>
<Route exact path='/' component={Home}/>
</Switch>
);
}
}
export default Main;
router not routing to /admin but it is routing to / , when i run the app and hit url 'localhost:8080/admin' it says white label error.
i am fully confused how to work with react routers and controllers, can anyone suggest me a way.
i achieved routing just by returning index.html for every requests in my spring boot controller.
Switch
with<Router></Router>
– Dunson