siamak jalili
siamak jalili

Reputation: 53

How can I use routing in ReactJs?

I used HashRouter from react-router-dom. When I use Router pages are not found. what is the best way to remove HashRouter from URL? My server side project is asp.net MVC and Use webapi2. IIS6

Upvotes: 2

Views: 326

Answers (1)

Ankit Verma
Ankit Verma

Reputation: 236

In App.js file -

import React, { Component } from 'react'
import './App.css'
import {BrowserRouter as Router, Switch, Route} from 'react-router-dom'
import Header from './component/header/header'
import Test from './component/test/test'
import Speaking from './component/test/speaking/speaking'
import Demo from './component/test/speaking/demo/demo'

 class App extends Component {
   render () {
      return (
          <Router>
             <div >
          <Header />
          <Switch>
             <Route path='/' component={Demo} />
             <Route path='/test' component={Test} />
             <Route path='/Speaking' component={Speaking } />
          </Switch>
            </div>
         </Router>
       )
      }
     }

    export default App

Upvotes: 1

Related Questions