Kozea / formol

An opinionated react form framework.
MIT License
190 stars 17 forks source link

Fix the register function #73

Closed notAro14 closed 3 years ago

notAro14 commented 3 years ago

Context

When two or more Fields are used either inside the Conditional component or both in their own Conditional with the same show condition, only the last Field receive its initial value set in item attribute via Formol component.

The cause

When a Field is mounted, the register function is executed to register the component in transientItem variable. But due to the async nature of setState, the transientItem between Fields registration stays the same.

I think this commit is an attempt to fix the bug https://github.com/Kozea/formol/commit/c12d07cdb293e9012b8062df11dacc25a1c5121e But it seems to appear again https://github.com/Kozea/formol/issues/62

coveralls commented 3 years ago

Pull Request Test Coverage Report for Build 434


Totals Coverage Status
Change from base Build 425: 0.0%
Covered Lines: 734
Relevant Lines: 734

💛 - Coveralls
notAro14 commented 3 years ago

@gentooboontoo @cmigazzi I add the test https://github.com/Kozea/formol/pull/73/commits/8101ebc868cbc1ed4df305fbe07ef8a979b22fb0 for the fix. You can now review.