Unhandled Runtime Error
Top of the code
Other part of the code
How can I fix that?
5 Replies
You cannot call react hook inside if statement or loops it need to be at the top of component : react.dev look at hooks : https://react.dev/learn#using-hooks
Quick Start – React
The library for web and native user interfaces
You could use reactquery enabled pattern : https://tanstack.com/query/v4/docs/react/guides/disabling-queries
Disabling/Pausing Queries | TanStack Query Docs
If you ever want to disable a query from automatically running, you can use the enabled = false option.
When enabled is false:
Also you should probably use an i18n lib for traduction
Instead of using trpc depending on your need
But how can I do this if I have to pass arguments such as text within a textarea?
I mean
by putting it at the top
useState
two way binding inputs
enabled opts on query