form
form copied to clipboard
swapValues error on nested fields
Minimal example here: https://codesandbox.io/s/react-form-basic-form-hooks-only-6muwk?fontsize=14&hidenavigation=1&theme=dark
To reproduce:
- Add two nested "Nicknames"
- Try to move them up/down using the controls, which calls swapValues on their indexes
- Observe
str.replace is not a functionerror
It looks like the fields get passed as an array like ['nicknames', '0'] and ['nicknames', '1'] in swapFieldValues:
https://github.com/tannerlinsley/react-form/blob/master/src/hooks/useForm.js#L386
But getBy calls makePathArray which expects a string here:
https://github.com/tannerlinsley/react-form/blob/master/src/utils.js#L35
https://github.com/tannerlinsley/react-form/blob/master/src/utils.js#L101
I'm not sure if the correct solution is passing in a string from swapFieldValues or to modify makePathArray to check if it's already an array.