Current url holds data to display or show into view in segment query string. In this article, we will discuss about how to get current page url in react application. In this tutorial, I will show you reactjs get current page url example.
Javascript window.location.href
property holds the current url which you can use it into React. Let's see below example.
import React from 'react'
export default class Home extends React.Component{
render() {
const currentUrl = window.location.href;
return(
<p>
{ currentUrl }
</p>
);
}
}
This way you can get current url into React application. I hope it will help you.