You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I currently have a scenario where one field is dependent on another—something roughly along the lines of a country and state/territory select, where changing the country should clear any previously selected state/territory value. The solution I came up with is:
Create a formRef with useRef() pointing to the latest object returned by useReactoForm()
Call setTimeout(countryDidChange, delay) whenever the country field onChange() event has fired
countryDidChange does something like formRef.current.getInputProps('state').onChange(null);
This works, but seems inelegant. I was wondering if this is something others had come across—and if so, is there a recommended pattern for handling these cases?
The text was updated successfully, but these errors were encountered:
Thanks for your work on
reacto-form
!I currently have a scenario where one field is dependent on another—something roughly along the lines of a country and state/territory select, where changing the country should clear any previously selected state/territory value. The solution I came up with is:
formRef
withuseRef()
pointing to the latest object returned byuseReactoForm()
setTimeout(countryDidChange, delay)
whenever the country fieldonChange()
event has firedcountryDidChange
does something likeformRef.current.getInputProps('state').onChange(null)
;This works, but seems inelegant. I was wondering if this is something others had come across—and if so, is there a recommended pattern for handling these cases?
The text was updated successfully, but these errors were encountered: