Solid.js + tanstack/solid-query multiple refetch problem on error

Hi all, I'm using tanstack for client-server communication. And I'm turning the hook to createMemo if I want it to be re-mounted when I change query-params. But, for some reason, if such a hook receives an error from the server, it mounts infinitely many times. How to solve this problem?

const eventsQuery = createMemo(() =>
messagesIds().length
? getScheduledEventsApiFrontendScheduledEventsGetQuery(
{
scheduled_event_ids: messagesIds(),
},
{
query: {
onSuccess: res => {
if (JSON.stringify(res) !== '{}')
setAllMessages(JSON.parse(JSON.stringify(res)));
},
onError: () => {},
enabled: !!messagesIds().length,
},
},
)
: null,
);
photo_2025-04-01_14-24-28.jpg
Was this page helpful?