useLocation and useHistory inside useEffect #8173
              
                Unanswered
              
          
                  
                    
                      PawelMorawian
                    
                  
                
                  asked this question in
                Q&A
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am trying to create a hook that takes a state as a parameter and pushed its content as URL search parameters.
This is my code so far:
I call this hook with:
This code works, but I get an eslint warning:
React Hook useEffect has a missing dependency: 'location'. Either include it or remove the dependency arrayWhen I add the location to the dependency hook, the hooks fstops working and I get the following error:
SecurityError: The operation is insecure.Could someone please explain to me why I can't add
locationto the dependency hook and tell if my code is valid and I can just ignore the warning.Thank you
Beta Was this translation helpful? Give feedback.
All reactions