final-form / react-final-form

🏁 High performance subscription-based form state management for React
https://final-form.org/react
MIT License
7.39k stars 481 forks source link

Infinite re-render (loop) with react-select (multi) initialValues #754

Open l1zard opened 4 years ago

l1zard commented 4 years ago

Are you submitting a bug report or a feature request?

Bug

What is the current behavior?

Infinite re-render (loop) after set initialValues as array []

What is the expected behavior?

No infinite loop

Sandbox Link

https://codesandbox.io/s/busy-bouman-y680m

What's your environment?

Other information

React Final Form's code sandbox

callmeberzerker commented 4 years ago

Hi @l1zard

The issue you are having is that you are re-creating the initialValue list on every-render to infinity.

I solved your issue in this sandbox. (by basically keeping the same array reference for the initial value in state)

https://codesandbox.io/s/friendly-forest-xbzjc

ImADrafter commented 4 years ago

This also happen with native Select. CodeSandbox