jonathanj
jonathanj
TtRPC
Created by Catlike on 5/7/2024 in #❓-help
useUtils changes at every render and causes useEffect to be called continuously
e.g.
const utils = trpc.useUtils();
useEffect(() => () => utils.user.example.invalidate(), [utils]);
const utils = trpc.useUtils();
useEffect(() => () => utils.user.example.invalidate(), [utils]);
4 replies
TtRPC
Created by Catlike on 5/7/2024 in #❓-help
useUtils changes at every render and causes useEffect to be called continuously
I'm not sure if it's documented somewhere, I might have read through the code trying to answer this, but I think your dependency should be the result of useUtils only. The result of useUtils is a Proxy object and the useUtils property is specially handled to memoize the context result. Accessing other properties on the proxy creates a new reference every time you access the property.
4 replies
TtRPC
Created by Thembo Coach on 10/24/2023 in #❓-help
TypeError: Cannot read properties of null (reading '_def')
Empty router works fine, admittedly null was not a good original choice (my fault).
8 replies