Formsy onChange model missing value object methods
See original GitHub issueHi,
For context I have created a datepicker using withFormsy()
. The date selected by the user is a Moment.js object which has a bunch of methods for manipulating and formatting the date.
The model on the Formsy prop onChange((model)=>{ })
remove all the __proto__
methods on the object.
I think this is down to the cloneIfObject()
method in https://github.com/formsy/formsy-react/blob/6fcc682e1dae82dd5643a744f587713f4d8a9ced/src/utils.ts#L47 which is spreading the current model values.
This doesn’t seem to be the same behaviour with setting the value using the setValue()
prop in the withFormsy
component.
This was working pre the v1 to v2 update.
Is the cloneIfObject
method needed?
Many thanks
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
formsy-react/API.md at master - GitHub
"onChange" triggers when setValue is called on your form elements. It is also triggered when dynamic form elements have been added to the...
Read more >How to can I use onChange on React Hook Form Version 7.0
For those new to this thread, the problem with just adding onChange is that in RHF v7.x calling ...register('name') spreads an object containing ......
Read more >Set Control Value/Text OnChange - Power Platform Community
Solved: Could we please have the ability to set a control value based on the change of another control? Example: TEXTBOX1: Enter your...
Read more >SCR19: Using an onchange event on a select element ... - W3C
The objective of this technique is to demonstrate how to correctly use an onchange event with a select element to update other elements...
Read more >useForm | React Hook Form - Simple React forms validation
Their default values should be an empty object. For example: {} . The keys of the error object should match the name values...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After some playing yesterday I have worked around it by using the model value to create another moment object.
Makes sense what you are saying about only supporting the JSON so happy for this issue to be closed. Thanks
It doesn’t appear so. I’m going to write a test-case to get more definitive information.
Also, one additional option is that objects like this just shouldn’t be supported. In that case, you would want to use something like an ISO 8601 string as your actual “value” and either use moment only internally in your input component, only external to the form, or in both. What do you think about that?
There’s some sense in formsy only supporting things that could be sent to or from a server as JSON.