Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useFieldArray doesn't work in next.js #864

Closed
igo opened this issue Jan 19, 2020 · 5 comments
Closed

useFieldArray doesn't work in next.js #864

igo opened this issue Jan 19, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@igo
Copy link

igo commented Jan 19, 2020

useFieldArray doesn't work in next.js and produces ReferenceError: performance is not defined.

[ wait ]  compiling ...
[ ready ] compiled successfully - ready on http://localhost:3000
ReferenceError: performance is not defined
    at generateId (/Users/igo/workspaces/hello-next/node_modules/react-hook-form/dist/react-hook-form.js:1247:15)
    at appendId (/Users/igo/workspaces/hello-next/node_modules/react-hook-form/dist/react-hook-form.js:1254:93)
    at /Users/igo/workspaces/hello-next/node_modules/react-hook-form/dist/react-hook-form.js:1255:67
    at Array.map (<anonymous>)
    at mapIds (/Users/igo/workspaces/hello-next/node_modules/react-hook-form/dist/react-hook-form.js:1255:54)
    at useFieldArray (/Users/igo/workspaces/hello-next/node_modules/react-hook-form/dist/react-hook-form.js:1288:47)
    at App (/Users/igo/workspaces/hello-next/.next/server/static/development/pages/index.js:149:76)
    at processChild (/Users/igo/workspaces/hello-next/node_modules/react-dom/cjs/react-dom-server.node.development.js:3204:14)
    at resolve (/Users/igo/workspaces/hello-next/node_modules/react-dom/cjs/react-dom-server.node.development.js:3124:5)
    at ReactDOMServerRenderer.render (/Users/igo/workspaces/hello-next/node_modules/react-dom/cjs/react-dom-server.node.development.js:3598:22)
    at ReactDOMServerRenderer.read (/Users/igo/workspaces/hello-next/node_modules/react-dom/cjs/react-dom-server.node.development.js:3536:29)
    at renderToString (/Users/igo/workspaces/hello-next/node_modules/react-dom/cjs/react-dom-server.node.development.js:4245:27)
    at render (/Users/igo/workspaces/hello-next/node_modules/next/dist/next-server/server/render.js:80:16)
    at Object.renderPage (/Users/igo/workspaces/hello-next/node_modules/next/dist/next-server/server/render.js:291:16)
    at /Users/igo/workspaces/hello-next/.next/server/static/development/pages/_document.js:799:21
    at Generator.next (<anonymous>)

To Reproduce
Steps to reproduce the behavior:

  1. Start empty next.js project https://nextjs.org/learn/basics/getting-started/setup
  2. Create page and add demo from https://codesandbox.io/s/react-hook-form-usefieldarray-vy8fv
  3. Start nextjs and see error

Desktop (please complete the following information):

  • OS: MacOS
  • Node 12
@bluebill1049 bluebill1049 added the bug Something isn't working label Jan 19, 2020
@bluebill1049 bluebill1049 self-assigned this Jan 19, 2020
bluebill1049 added a commit that referenced this issue Jan 19, 2020
@bluebill1049
Copy link
Member

can you test out this beta version: react-hook-form@4.5.7-beta.2

@iufd
Copy link

iufd commented Jan 20, 2020

Fix doesn't work. Did you try it @bluebill1049 ?

ReferenceError: window is not defined
    at useForm (C:\Users\admin\playground\hello-next\node_modules\react-hook-form\dist\react-hook-form.js:610:47)
    at App (C:\Users\admin\playground\hello-next\.next\server\static\development\pages\form.js:138:70)
    at processChild (C:\Users\admin\playground\hello-next\node_modules\react-dom\cjs\react-dom-server.node.development.js:3204:14)
    at resolve (C:\Users\admin\playground\hello-next\node_modules\react-dom\cjs\react-dom-server.node.development.js:3124:5)
    at ReactDOMServerRenderer.render (C:\Users\admin\playground\hello-next\node_modules\react-dom\cjs\react-dom-server.node.development.js:3598:22)
    at ReactDOMServerRenderer.read (C:\Users\admin\playground\hello-next\node_modules\react-dom\cjs\react-dom-server.node.development.js:3536:29)
    at renderToString (C:\Users\admin\playground\hello-next\node_modules\react-dom\cjs\react-dom-server.node.development.js:4245:27)
    at render (C:\Users\admin\playground\hello-next\node_modules\next\dist\next-server\server\render.js:80:16)
    at Object.renderPage (C:\Users\admin\playground\hello-next\node_modules\next\dist\next-server\server\render.js:291:16)
    at C:\Users\admin\playground\hello-next\.next\server\static\development\pages\_document.js:799:21
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (C:\Users\admin\playground\hello-next\.next\server\static\development\pages\_document.js:239:24)
    at _next (C:\Users\admin\playground\hello-next\.next\server\static\development\pages\_document.js:261:9)
    at C:\Users\admin\playground\hello-next\.next\server\static\development\pages\_document.js:268:7
    at new Promise (<anonymous>)
    at new F (C:\Users\admin\playground\hello-next\node_modules\core-js\library\modules\_export.js:36:28)

@bluebill1049 bluebill1049 reopened this Jan 20, 2020
@bluebill1049
Copy link
Member

@iufd didn't run against next.js can you help test this beta: react-hook-form@4.5.7-beta.3

@bluebill1049
Copy link
Member

tested with next.js

@iufd
Copy link

iufd commented Jan 20, 2020

Yep, it's working now

@bluebill1049 bluebill1049 removed their assignment Aug 12, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants