kettanaito / react-advanced-form

Functional reactive forms. Multi-layer validation, custom styling, field grouping, reactive props, and much more.
https://redd.gitbook.io/react-advanced-form
MIT License
217 stars 24 forks source link

setValues: RangeError: Maximum call stack size exceeded #327

Closed kettanaito closed 6 years ago

kettanaito commented 6 years ago

Environment

What

Current behavior

Calling formRef.setValues() for a certain forms results into max call stack size exceeded exception.

Uncaught (in promise) RangeError: Maximum call stack size exceeded
    at Arguments.slice (<anonymous>)
    at eval (index.development.js:3257)
    at f2 (index.development.js:3106)
    at eval (index.development.js:4589)
    at f1 (index.development.js:3063)
    at createLeavesGetter (index.development.js:11329)
    at eval (index.development.js:11342)
    at eval (index.development.js:3218)
    at eval (index.development.js:2842)
    at when (index.development.js:6135)
    at eval (index.development.js:3152)
    at f1 (index.development.js:3063)
    at _map (index.development.js:3911)
    at map (index.development.js:4666)
    at eval (index.development.js:3272)
    at f2 (index.development.js:3106)

Expected behavior

Calling formRef.setValues() must be safe, and have no memory leaks.

Why

I think that the algorithm is being caught in the infinite loop during this iteration:

https://github.com/kettanaito/react-advanced-form/blob/d36e4db5caf3d3e363a1f4dd72c20bbbcf25db73/src/components/Form.jsx#L277

kettanaito commented 6 years ago

Eliminated the infinite loop by reducing the amount of iterations happening in Form.setValues (78f1caea1ffeda54cd74a4593be645d82ce360ca). Relative field validation is applied as a part of fields evolving.