Drife Code blogs and ai

Create routes in react app for first time

Cover Image for Create routes in react app for first time
Front end developer react Js marwin brown
marwinbrown

It's pretty simple to get started with routing in react. You just have to use react-router-dom.

1. Install react-router-dom , using command
npm i react-router-dom

2. After installation go to your App.js or index.js file and import the following from react-router-dom

import { BrowserRouter, Route, Routes } from"react-router-dom";

After this go to your app or main function and call your routes like this

<BrowserRouter>

<Routes>

<Route path="/" element={<Home/>} />

</Routes>

</BrowserRouter>

And import the pages from the rest file for eg. in my case

import Home from "./screens/home";

Thats it!!


More Stories

Cover Image for How I Created a Mobile App Portfolio with AI in Just One Hour

How I Created a Mobile App Portfolio with AI in Just One Hour

Discover how I created a professional mobile app portfolio for a client in just one hour using Vercel's v0 AI. From generating the base code with a simple prompt to customizing it and deploying it on Vercel, this blog details the step-by-step process—highlighting the power of AI in modern web development. And yes, even this blog was crafted with a little help from AI! 🚀

senior developer gautam swami
Gautam swami
Cover Image for Using wireless debugging for Device connection and how to connect android device over wifi for development

Using wireless debugging for Device connection and how to connect android device over wifi for development

Using wireless debugging for Device connection and how to connect android device over wifi for development

senior developer gautam swami
Gautam swami