Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
Created July 12, 2017 22:44
Show Gist options
  • Star 29 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jaytaylor/b14716671ae6a8cd057bd6d849670238 to your computer and use it in GitHub Desktop.
Save jaytaylor/b14716671ae6a8cd057bd6d849670238 to your computer and use it in GitHub Desktop.
Solution for "Unexpected use of 'location'" React error.
React: Unexpected use of 'location';

Solution: Use window.location instead of bare location.

@beachstrider
Copy link

Thanks!

@CarolineFang1998
Copy link

Thanks

@raygyli
Copy link

raygyli commented Jul 5, 2023

Thanks!

@pratik9818
Copy link

why we have to access location object through window even window is global object , can anyone answer it ,it will help me and other as well
--thank you.

@hossein-ketabi
Copy link

Thanks

@luuksg12
Copy link

luuksg12 commented Sep 4, 2023

Thanks

@563rajesh
Copy link

thanks

@ekeboetuk
Copy link

why we have to access location object through window even window is global object , can anyone answer it ,it will help me and other as well --thank you.

Please did you get a response to this anywhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment