indes.js (npm start this file)
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router } from 'react-router-dom';
import Routes from './routes';
ReactDOM.render(
<Router>
<Routes />
</Router>,
document.getElementById('root') // Use getElementById with the id attribute of the target element
);
the routes.js file for routing
import React from 'react';
import { Routes ,Route } from 'react-router-dom';
import Home from './components/Home';
import About from './components/About';
import Contact from './components/Contacts';
import NotFound from './components/NotFound';
const Rooutes = () => {
return (
<Routes>
<Route exact path="/" element={Home} />
<Route path="/about" element={About} />
<Route path="/contact" element={Contact} />
<Route element={NotFound} />
</Routes>
);
};
export default Rooutes;
and one html file of used ones like this:
import React from 'react';
const About = () => {
return (
<>
h1 about Component
</>
);
};
export default About;
everything just works perfectly. no errors detected and the npm compiles successfully but no html element is rendered to the browser, any advice/help?
2
Answers
resoved it, I forgot to fukin return it in
it will work if you do this