Skip to content

Commit

Permalink
Setting Up Routing & Routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ch-sriram committed Aug 14, 2020
1 parent 8b34257 commit 3c64601
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ Firebase Common API Endpoint: <https://burger-builder-ram.firebaseio.com/>
### Adding Routing using `react-router`

1. Building the `<Checkout />` & `<CheckoutSummary />` Components: [Commit Details](https://github.com/Ch-sriram/burger-builder/commit/bb4ab26d36667835423c08ca13c66db4be548c82)
2. Setting Up Routing & Routes **`npm i --save react-router-dom`**: [Commit Details]()
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "^3.4.3",
"styled-components": "^5.1.1"
},
"scripts": {
Expand Down
7 changes: 5 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// LIBRARY IMPORTS
import React, { Component } from 'react';
import { Route, Switch } from 'react-router-dom';

// CUSTOM COMPONENTS
import Layout from './components/Layout/Layout.component';
Expand All @@ -11,8 +12,10 @@ class App extends Component {
return (
<div>
<Layout>
<BurgerBuilder />
<Checkout />
<Switch>
<Route path="/checkout" component={Checkout} />
<Route path="/" component={BurgerBuilder} />
</Switch>
</Layout>
</div>
);
Expand Down
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(
<App />,
document.getElementById('root')
<BrowserRouter>
<App />
</BrowserRouter>,
document.getElementById("root")
);

// If you want your app to work offline and load faster, you can change
Expand Down

0 comments on commit 3c64601

Please sign in to comment.