Changing kwargs does not re-run use_query?
              
              #287
            
            
              
                
                  
                  
                    Answered
                  
                  by
                    Archmonger
                  
              
          
                  
                    
                      dickermoshe
                    
                  
                
                  asked this question in
                Problem
              
            -
| I have a simple text input to search products async def get_products(q: str):
    if not q:
        return Product.objects.none()
    return await database_sync_to_async(lambda: Product.objects.filter(name__icontains=q))()
@component
def textbox(recipient: str):
    text, set_text = use_state("")
    result = hooks.use_query(get_products, {"q": text})
    ...However when the search text changes, the query is not ran again. | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            Archmonger
          
      
      
        Mar 20, 2025 
      
    
    Replies: 1 comment
-
| 
 In order to re-run it, you must call  @component
def textbox(recipient: str):
    text, set_text = use_state("")
    result = hooks.use_query(get_products, {"q": text})
    
    def on_submit(event):
        set_text(event["target"]["value"])
        result.refetch()
    ... | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
      Answer selected by
        Archmonger
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
use_querydoes not automatically re-run if kwargs have changed.In order to re-run it, you must call
query.refetch().