I am getting a 500 Internal Server Error in the XHR request. And the frontend throws the error:
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
I added the api/preview.tsx inside my pages/[lang] directory and after previewing http://localhost:3000/de/api/preview?token=<TOKEN>, I do not get the server error anymore, but history, location, token and documentId are all undefined.
Just change the needed values to match your configuration, in this case: The path for the Link Resolver, the apiEndpoint, and the accessToken if you have one.
I think we’re getting closer here - but now I see this error message:
Uncaught Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.
in Preview (at _app.tsx:67)
I guess this is because the Preview component doesn’t return anything. Do you have any idea?