Next.js Discord

Discord Forum

Jest + useOptimistic hook - Unsupported Server Component type: undefined

Unanswered
Catla posted this in #help-forum
Open in Discord
Avatar
CatlaOP
useOptimistic hook works out of the box on the last version of NextJS but not with Jest, I had to update React version
    "next": "^14.0.4",
    ...
    "react": "18.3.0-canary-c5b937576-20231219",
    "react-dom": "18.3.0-canary-c5b937576-20231219",
    ...
    "jest": "^29.7.0",
    "jest-environment-jsdom": "^29.7.0",

Now the test works with useOptimistic new hook, the problem it that NextJS stopped working:

Check your code at page.tsx:27.
Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check your code at page.tsx:27.
 ⨯ Error: Unsupported Server Component type: undefined

0 Replies