Hi Guys i want to create a web page that change pages with Navbars so i want to use bootstrap and react-route-dom to create this but before i use bootstrap its show nothing some kind of errors may occurred that i didn’t see i post my code here i just create one page and used it in App.jsx file but it’s show nothing but when i use home page as in App file’s return function it works pretty much good and its ok i can’t find any error it’s just say’s
No routes matched location “/”
here is my index.jsx file:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './components/pages/App';
import reportWebVitals from './reportWebVitals';
const rootElement = document.getElementById("root");
ReactDOM.render(
<App/>,
rootElement
)
;
reportWebVitals();
and here is the App.jsx file:
import '../../App.css';
import 'bootstrap/dist/css/bootstrap.min.css';
import React from "react";
import {BrowserRouter as Router, Route, Routes} from 'react-router-dom';
import Home from './home';
import HeaderBar from '../layout/HeaderBar';
function App() {
return (
<Router >
<div>
<HeaderBar/>
<Routes>
<Route exact path='./pages/home' component ={Home}/>
</Routes>
</div>
</Router>
);
}
export default App;
And my Home file:
import React from 'react';
const Home = () => {
return (
<div className="container">
<h1 className='display-5 text-uppercase py-5 text-center'>
Welcome to JavaScript World
</h1>
</div>
);
};
export default Home;
and finally this is my package.json:
{
"name": "forex_trader",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"bootstrap": "^5.1.3",
"react": "^17.0.2",
"react-bootstrap": "^2.1.0",
"react-dom": "^17.0.2",
"react-router-bootstrap": "^0.26.0",
"react-router-dom": "^6.2.1",
"react-scripts": "5.0.0",
"styled-components": "^5.3.3",
"web-vitals": "^2.1.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}