Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
Created July 12, 2017 22:44
Show Gist options
  • 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.

@darkwoodbeats
Copy link

this works, thanks!

@beachstrider
Copy link

Thanks!

@CarolineFang1998
Copy link

Thanks

@R4YGUL4RiZ3
Copy link

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

@ekebobrown
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?

@CaioLuColaco
Copy link

thanks

@stefaniafrolovafrolov
Copy link

Спасибо) Это сработало) Ранее я window с location не использовал.

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