Skip to content

Instantly share code, notes, and snippets.

@gtchakama
Created February 10, 2023 18:42
Show Gist options
  • Select an option

  • Save gtchakama/81f93bccc3f588276672237525655e7c to your computer and use it in GitHub Desktop.

Select an option

Save gtchakama/81f93bccc3f588276672237525655e7c to your computer and use it in GitHub Desktop.
When using React hooks there is no access to access to this.props.location. To capture url parameters use window object.
const getParams = () => {
const search = window.location.search;
const params = new URLSearchParams(search);
const TokenParam: any = params.get('token');
console.log(TokenParam);
}
useEffect(() => {
getParams()
}, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment