-
-
Notifications
You must be signed in to change notification settings - Fork 22
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.
Shouldn't the query be reran when the kwargs change?
If not, how would I do this?
Beta Was this translation helpful? Give feedback.
All reactions
Answered by
Archmonger
Mar 20, 2025
use_query does not automatically re-run if kwargs have changed.
In order to re-run it, you must call query.refetch().
@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() ...
Replies: 1 comment
-
use_query does not automatically re-run if kwargs have changed.
In order to re-run it, you must call query.refetch().
@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.
All reactions
0 replies
Answer selected by
Archmonger
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment