How to figure out the changed formData
object property from inside onChange
callback?
#4130
Open
1 task done
Labels
Prerequisites
What theme are you using?
core
What is your question?
New
formData
provided on the first parameter ofonChange
form handler seems to be an edited deep copy of the previous state (unchangedformData
properties do not retain reference). I need to work around this to live-detect state changes between initial and currentformData
states with reasonable performance on large forms.This comment claims to have solved the issue, but seems like a rather bloaty approach.
This comment seems to claim that the
id
prop provided as a second argument should be able to solve this.I attempted to parse the changed
formData
property name like this:And it doest the trick most of the time, but on further testing I found out that when I call change the value in an
anyOf
select on a property namedvalidator
, I get thisid
in the callback:which results in the incorrect property being updated in my state (
validator__anyof_select
, when the property is simplyvalidator
).I could easily check and adjust for the
__anyof_select
suffix, but I'm not sure what other cases I can encounter.Is this documented somewhere? How can I reliably parse the actual
formData
object property name?Thank you very much!
The text was updated successfully, but these errors were encountered: