useOne did not recall when id from useParsed change
useOne did not recall when id from useParsed change
3 Replies
Hi @tingadev. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the knowledge sources provided, there isn't enough specific information to directly address the issue of
useOne
not recalling when the id
from useParsed
changes. However, I can provide some relevant information and a potential workaround based on the available documentation.
The useOne
hook is designed to fetch a single record from an API endpoint. It typically uses the id
parameter to determine which record to fetch. When using useOne
with useParsed
, you might encounter issues if the hook doesn't automatically react to changes in the id
.
A potential solution to this problem is to manually control the id
passed to useOne
using the setId
function. This approach is mentioned in the useForm documentation:
By using this method, you can ensure that the id
is updated when it changes in the URL.
Alternatively, you could consider using the queryOptions
parameter of useOne
to control when the query should run. For example:
This approach ensures that the query only runs when there's a valid id
.
If these suggestions don't solve your specific issue, you might want to consider creating a GitHub issue for the Refine project, as this could potentially be a bug that needs to be addressed by the Refine team.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@761921731505946634> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
wise-white•2d ago
Hello @tingadev, can you provide reproducible example please? In my tests, it's worked . maybe I couldn't recreate the problem