-
Notifications
You must be signed in to change notification settings - Fork 16
Description
I've been using ErrorMessage with no issues on NextJS client-rendered pages. Based on the documentation, I haven't been passing the errors
object to the ErrorMessage component since I'm using a FormProvider.
However, I just tried to use an ErrorMessage in a form on a NextJS statically exported page and it throws an error that says TypeError: Cannot read properties of null (reading 'formState')
.
After looking through the issues here and reading #52, I tried fetching the errors
object inside my component using useFormContext
, and passing this to the ErrorMessage. It seems to have resolved the issue.
This workaround works for me, but I wanted to see if this is expected behavior when exporting a static page.
Versions:
NextJS v12.1.0
React-Hook-Form v7.27.1
@hookform/error-message v2.0.0