ratty-blush
ratty-blush10mo ago

conditional useSelect

As hooks can only be called at top level, is there any way possible to call useSelect hook only when a particular state variable is set.
4 Replies
kapa.ai
kapa.ai10mo ago
Hi @dreamer9067. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. However, it's important to note that React's Rules of Hooks (https://reactjs.org/docs/hooks-rules.html) state that hooks should not be called conditionally. This means that you cannot call a hook like useSelect only when a particular state variable is set. Hooks must be called at the top level of your component. If you need to perform an action based on a state variable, consider using an effect hook like useEffect that runs when your state changes. For more information on how to use hooks in refine, you can check out the documentation (https://refine.dev/docs). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai10mo ago
<@560876002046377984> kapa.ai is still learning and improving, please let us know how it did by reacting below
xenial-black
xenial-black10mo ago
Hello @dreamer9067 all data hooks have enabled property inside queryOptions. when this false, request will not sent https://refine.dev/docs/api-reference/core/hooks/useSelect/#queryoptions
useSelect | refine
useSelect hook allows you to manage any select (like a Html `` tag, React Select, etc...) component. Since it is designed as headless, It expects you to handle the UI.
ratty-blush
ratty-blush10mo ago
awesome thanks @alicanerdurmaz