Created new routes with router config

merge-requests/56/head
Jayasanka 6 years ago
parent 15f38ba101
commit 536a2ca81b

@ -16,11 +16,6 @@ class App extends React.Component {
return (
<Router>
<div>
<ul>
<li><Link to="/publisher/tacos">Tacos</Link></li>
<li><Link to="/publisher/sandwiches">Sandwiches</Link></li>
</ul>
{this.routes.map((route) => (
<RouteWithSubRoutes key={route.path} {...route} />
))}

@ -4,7 +4,6 @@ class RouteWithSubRoutes extends React.Component{
props;
constructor(props){
super(props);
console.log(props);
this.props = props;
}
render() {

@ -1,75 +1,12 @@
// import React from 'react';
import React from 'react';
import ReactDOM from 'react-dom';
// import './index.css';
import './index.css';
import * as serviceWorker from './serviceWorker';
// import { renderRoutes } from "react-router-config";
// import Dashboard from "./pages/dashboard/Dashboard"
// import Login from "./pages/Login";
// import {BrowserRouter} from "react-router-dom";
//
//
// const routes = [
// {
// component: App,
// routes: [
// {
// path: "/publisher",
// exact: true,
// component: Dashboard,
// routes: [
// {
// path: "/publisher/a",
// component: Login
// }
// ]
// },
// {
// path: "/publisher/login",
// component: Login
// }
// ]
// }
// ];
//
// ReactDOM.render( <BrowserRouter>
// {/* kick it all off with the root route */}
// {renderRoutes(routes)}
// </BrowserRouter>, document.getElementById('root'));
//
// // If you want your app to work offline and load faster, you can change
// // unregister() to register() below. Note this comes with some pitfalls.
// // Learn more about service workers: https://bit.ly/CRA-PWA
// serviceWorker.unregister();
import React from 'react';
import {
BrowserRouter as Router,
Route,
Link,
} from 'react-router-dom';
import RouteWithSubRoutes from "./components/RouteWithSubRoutes"
import App from "./App"
import Login from "./pages/Login"
import Dashboard from "./pages/dashboard/Dashboard"
const Sandwiches = () => <h2>Sandwiches</h2>
const Tacos = ({ routes }) => (
<div>
<h2>Tacos</h2>
<ul>
<li><Link to="/publisher/tacos/bus">Bus</Link></li>
<li><Link to="/publisher/tacos/cart">Cart</Link></li>
</ul>
{routes.map((route) => (
<RouteWithSubRoutes key={route.path} {...route} />
))}
</div>
)
const Bus = () => <h3>Bus</h3>
const Cart = () => <h3>Cart</h3>
const routes = [
{
@ -77,12 +14,12 @@ const routes = [
component: Login
},
{
path: '/publisher/tacos',
component: Tacos,
path: '/publisher/dashboard',
component: Dashboard,
routes: [
{
path: '/publisher/tacos/bus',
component: Login
path: '/publisher/dashboard/bus',
component: Bus
},
{
path: '/publisher/tacos/cart',
@ -92,30 +29,7 @@ const routes = [
}
]
// const RouteWithSubRoutes = (route) => (
// <Route path={route.path} render={(props) => (
// <route.component {...props} routes={route.routes}/>
// )}/>
// )
// class App extends React.Component {
// render() {
// return (
// <Router>
// <div>
// <ul>
// <li><Link to="/publisher/tacos">Tacos</Link></li>
// <li><Link to="/publisher/sandwiches">Sandwiches</Link></li>
// </ul>
//
// {routes.map((route) => (
// <RouteWithSubRoutes key={route.path} {...route} />
// ))}
// </div>
// </Router>
// )
// }
// }
ReactDOM.render( <App routes={routes}/>, document.getElementById('root'));

Loading…
Cancel
Save