0

i am new in react and trying to create App with sub-pages no issue with that i have done it but one small issue is my link "localhost:3000/" converted in "localhost:3000/#/"

Here is my code:

App.js

import React, { Component } from 'react';
import Header from './layouts/header.js';
import Footer from './layouts/footer.js';
import Sidebar from './layouts/sidebar.js';
import './css/style.scss';


  const App = (props) => {

    return (
      <div>
        <div className="sideBar">
          <Sidebar />
        </div>
        <div className="main_container">
          <Header />
            {props.children}
          <Footer />
        </div>
      </div>
    );

}

export default App;

routes.js

import React from 'react';
import { IndexRoute } from 'react-router';
import { BrowserRouter, Route, Switch } from 'react-router-dom';


/**
 * Import all page components here
 */
import App from './App.js';
import MainPage from './pages/homepage.js';
import About from './pages/about.js';

/**
 * All routes go here.
 * Don't forget to import the components above after adding new route.*/

export default (
    <Route path="/" component={App}>
      <IndexRoute component={MainPage} />
      <Route path="/about/:id" component={About} />
    </Route>
  );
jay khatri
  • 151
  • 1
  • 13

1 Answers1

0

Try with browserHistory

import { Router, Route, browserHistory } from 'react-router';


<Router history={browserHistory}>
  <Route path="/" component={App}>
   <IndexRoute component={MainPage} />
   <Route path="/about/:id" component={About} />
  </Route>
</Router>

Reference: this question

halfer
  • 19,824
  • 17
  • 99
  • 186
Dhaval
  • 1,393
  • 5
  • 29
  • 55