React How To Get Current URL Value (Browser's Address Bar)

↔️ ↕️


hey guys in this tutorial I'm going to

show you how to get the current URL from

your browser's address bar in react

so here I have my basic react app

running in the browser

I have use statehook imported and I also

created this variable called URL which

by default will store the value of none

and that's what we're displaying in the

browser right now now this is because in

the react we have to use everything

through State and so that's why I

created that URL using the user

statehook now to track changes in this

variable we need to import use effect

hook and here I'm going to use the use

effect hook with an arrow function and

for the dependencies array of this use

effect we're going to use an empty array

so this use effect runs only once so now

let's get the current URL from address

Related queries:

how to get current url in node js
how to get current page in react native
react fetch url example
current url react router
reactjs fetch example
current url in react js
fetch url javascript example