Skip to content

Commit 4082592

Browse files
import all the files & give path using react-router-dom
1 parent c78dbe6 commit 4082592

File tree

10 files changed

+121
-17
lines changed

10 files changed

+121
-17
lines changed

package-lock.json

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@testing-library/user-event": "^13.5.0",
99
"react": "^18.2.0",
1010
"react-dom": "^18.2.0",
11+
"react-router-dom": "^6.22.3",
1112
"react-scripts": "5.0.1",
1213
"web-vitals": "^2.1.4"
1314
},

src/About.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
3+
const About = () => {
4+
return (
5+
<div>About</div>
6+
)
7+
}
8+
9+
export default About

src/App.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
import logo from './logo.svg';
21
import './App.css';
2+
import { BrowserRouter, Routes, Route } from 'react-router-dom';
3+
import Home from './Home';
4+
import About from './About';
5+
import Contact from './Contact';
6+
import SingleProduct from './SingleProduct';
7+
import Cart from './Cart';
8+
import ErrorPage from './ErrorPage';
39

410
function App() {
511
return (
6-
<div className="App">
7-
<header className="App-header">
8-
<img src={logo} className="App-logo" alt="logo" />
9-
<p>
10-
Edit <code>src/App.js</code> and save to reload.
11-
</p>
12-
<a
13-
className="App-link"
14-
href="https://reactjs.org"
15-
target="_blank"
16-
rel="noopener noreferrer"
17-
>
18-
Learn React
19-
</a>
20-
</header>
21-
</div>
12+
<BrowserRouter>
13+
<Routes>
14+
<Route path='/' element={<Home/>}/>
15+
<Route path='/about' element={<About/>}/>
16+
<Route path='/products' element={<Home/>}/>
17+
<Route path='/contact' element={<Contact/>}/>
18+
<Route path='/singleproduct' element={<SingleProduct/>}/>
19+
<Route path='/cart' element={<Cart/>}/>
20+
<Route path='*' element={<ErrorPage/>}/>
21+
</Routes>
22+
</BrowserRouter>
2223
);
2324
}
2425

src/Cart.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
3+
const Cart = () => {
4+
return (
5+
<div>Cart</div>
6+
)
7+
}
8+
9+
export default Cart

src/Contact.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
3+
const Contact = () => {
4+
return (
5+
<div>Contact</div>
6+
)
7+
}
8+
9+
export default Contact

src/ErrorPage.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
3+
const ErrorPage = () => {
4+
return (
5+
<div>ErrorPage</div>
6+
)
7+
}
8+
9+
export default ErrorPage

src/Home.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
3+
const Home = () => {
4+
return (
5+
<div>Home</div>
6+
)
7+
}
8+
9+
export default Home

src/Products.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
3+
const Products = () => {
4+
return (
5+
<div>Products</div>
6+
)
7+
}
8+
9+
export default Products

src/SingleProduct.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
3+
const SingleProduct = () => {
4+
return (
5+
<div>SingleProduct</div>
6+
)
7+
}
8+
9+
export default SingleProduct

0 commit comments

Comments
 (0)