Routing
Routing
// Home Component
const Home = () => {
return <div style={{ backgroundColor: 'lightblue', height: '100vh' }}>Welcome to
Home Page</div>;
};
// Projects Component
const Projects = () => {
return <div style={{ backgroundColor: 'lightgreen', height: '100vh' }}>Welcome to
Projects Page</div>;
};
// Contact Component
const Contact = () => {
return <div style={{ backgroundColor: 'lightcoral', height: '100vh' }}>Welcome to
Contact Page</div>;
};
// App Component
const App = () => {
return (
<Router>
<Navbar />
<Switch>
<Route path="/" exact component={Home} />
<Route path="/projects" component={Projects} />
<Route path="/contact" component={Contact} />
</Switch>
</Router>
);
};
ReactDOM.render(<App />, document.getElementById('root'));