Next.js Discord

Discord Forum

Error.tsx client components

Unanswered
Siamese posted this in #help-forum
Open in Discord
SiameseOP
I follow the documentation using error.tsx but I got this big warning error :

But i add exactly the same code :

'use client'; // Error components must be Client Components

import { useEffect } from 'react';

export default function Error({
  error,
  reset,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  useEffect(() => {
    // Log the error to an error reporting service
    console.error(error);
  }, [error]);

  return (
    <div>
      <h2>Something went wrong!</h2>
      <button
        onClick={
          // Attempt to recover by trying to re-render the segment
          () => reset()
        }
      >
        Try again
      </button>
    </div>
  );
}


I use a mono repo application with NX !
Next is up to next : Next.js v13.4.9

15 Replies

Just add "use client" to the top of the error.tsx file.
SiameseOP
I already to that @elswell
Look at the quesiton
Chinese perch
did you ever solve this @Siamese
I'm also having the exact same error. Also using NX
SiameseOP
Hi @Chinese perch
No but it's no resolve
with next version
but generaly when i add error in the last folder like this :

path
error.tsx
page.tsx

it doesn't work well, i dot this no

path
page.tsx
error.tsx
Chinese perch
I've made some progress with this, will figure it out in the next few hours, will keep you updated.
Chinese perch
@Siamese would you be willing to drop your nx.json file? I think I've solved it...
Chinese perch
@Siamese I think I have an even easier fix. You ready for it?
npx nx migrate nx@16.6.0
npm i
npx nx migrate --run-migrations

Try again.
SiameseOP
ahaha ok i'll try thanks you
strange that nx create bug on nexjts
but my bug was no longer here since last versions