Next.js Discord

Discord Forum

notFound() causing client error

Unanswered
Small Münsterländer posted this in #help-forum
Open in Discord
Small MünsterländerOP
Using React Query, when i seem to check if the data is returned if not call notFound() else show page

const { data, isFetching } = useQuery({
    queryFn: async () => (await fetch(`/api/test`)).json(),
    queryKey: [TEST_QUERY, id],
  });

if (!data && !isFetching) notFound();

return ( Content )


Error:
app-index.js:34 Warning: You are mounting a new html component when a previous one has not first unmounted. It is an error to render more than one html component at a time and attributes and children of these components will likely fail in unpredictable ways. Please only render a single instance of <html> and if you need to mount a new one, ensure any previous ones have unmounted first.


Is notFound() ssr-only?

1 Reply