react-final-form-hooks icon indicating copy to clipboard operation
react-final-form-hooks copied to clipboard

Maximum call stack size exceeded when initialValue is an array/object

Open Drogglbecher opened this issue 4 years ago • 3 comments

Are you submitting a bug report or a feature request?

bug report

What is the current behavior?

Since version 1.0.1 it seems, that values initialized with an empty array leads to a Maximum call stack size exceeded error.

What is the expected behavior?

That I can operate on this array like in version 1.0.0-alpha.1.

Sandbox Link

https://codesandbox.io/s/react-final-form-hooks-simple-example-82tcn?fontsize=14&hidenavigation=1&theme=dark&file=/src/index.js

You can switch between the versions, which should result in the described behaviour. Could it be, that this use case handling arrays and objects should be handled differently now?

Drogglbecher avatar Apr 16 '20 15:04 Drogglbecher

I'm getting exact same error on my application. Does anybody know how to fix this?

adamklepacz avatar May 04 '20 11:05 adamklepacz

@Drogglbecher, @adamklepacz, you can memoize values to avoid re-rendering component.

Link to the working sandbox.: https://codesandbox.io/s/react-final-form-hooks-simple-example-84b9n?file=/src/index.js.

rudants avatar Jun 08 '20 13:06 rudants

I faced same issue. The form infinitely re-render if I use array format in initialvalues and validator. Took a deep look into react-final-form implementation and found they uses useConstant for validation, initialvalues, etc.

https://github.com/search?q=org%3Afinal-form+useConstant&type=code

ayame30 avatar Dec 17 '20 16:12 ayame30