Closed rrmesquita closed 2 weeks ago
Update: I just noticed that the current behaviour is very unexpected because it overrides previous changes not only from key-value calls but all setData
calls. Personally, I consider this a bug.
@rrmesquita Hey thanks for catching this! 🙏
And thanks for the review @derrickreimer and @thecrypticace 🤙
Just upgraded to 1.2.0 with hope that it'll be fixed but it seems to still be bugged.
This patch is not released yet, but will go out in the next version.
This is a proposal for changing the ergonomics of the key-value variant for the
setData
hook in React.Current behaviour
Using this simple form as an example:
It is expected that sequential calls to
setData
will update the form data accordingly. However, subsequent calls overwrite the changes made by the previous calls.Desired behaviour
Sequential
setData
calls use an updater function to batch the changes from multiple calls.This can be achieved using updater functions for the set functions in React. From React documentation:
It is worth noting that this only affects the key-value variant of the
setData
function, and if anyone is impacted by this change, they can switch to the object variant of thesetData
function.