Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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
Comment

get url react

window.location.href
Comment

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;
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: styled components import google font 
Javascript :: jquery on modal close event 
Javascript :: Cannot resolve taglib with uri http://java.sun.com/jsp/jstl/core 
Javascript :: node exporter service 
Javascript :: change href without reloading page js 
Javascript :: javascript compare number to string 
Javascript :: React CKEditor Custom build 
Javascript :: javascript is not null 
Javascript :: regexp object js 
Javascript :: countdown using vue 
Javascript :: moment().toDate(); 
Javascript :: moment js check if date is greater than 
Javascript :: javascript replace dash with space 
Javascript :: how to update the react version in next js app 
Javascript :: express routing 
Javascript :: javascript simulate click on element 
Javascript :: classname did not match server next js styled components 
Javascript :: javascript onclick select coordinates 
Javascript :: javascript loop an array 
Javascript :: eslint ignorel ine 
Javascript :: javascript sort array of objects by property alphabetically 
Javascript :: laravel react 
Javascript :: javascript function loop through array 
Javascript :: onclick toggle class react 
Javascript :: Unterminated string constant. 
Javascript :: react hook form with yup resolver 
Javascript :: firestore javascript delete document 
Javascript :: js  
Javascript :: jquery insert after element 
Javascript :: javascript two character integer 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =