Answers for "react get url"

2

get url react

window.location.href
Posted by: Guest on April-15-2020
0

How to get current URL with Javascript or React

const currentURL = window.location.href // returns the absolute URL of a page

const pathname = window.location.pathname //returns the current url minus the domain name
Posted by: Guest on October-13-2021
0

get current url react router

import {withRouter} from 'react-router-dom';

const SomeComponent = withRouter(props => <MyComponent {...props}/>);

class MyComponent extends React.Component {
  SomeMethod () {
    const {pathname} = this.props.location;
  }
}
Posted by: Guest on May-21-2020
0

get data from url using react

<Route path="/users/:id" component={UserPage}/>
Posted by: Guest on August-14-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language