I have a lib that returns me an float formatted string (ex: "4458.76") and i want to parse it to Float everytime the input ref is updated.
I tried use:
useEffect(() => {
registerField({
name: fieldName,
ref: inputRef.current,
path: parseFloat('state.numAsString'),
});
}, [fieldName, registerField]);
But everytime it return NaN
Someone can help me?
Hey @medeiroshudson,
The path is where unform look for a value on your component when form is submitted. Usually path is value. And in your registerField you provide path like a parseFloat of a string that's return NaN.
I didn't understood much your use case, but:
Describe more ur use case. Or if you could put this scenario on codesandbox and share with us, would be better. That's way someone could suggest a better solution.
Hey @medeiroshudson, since you need to return a float value, you can use the getValue method inside registerField.
I created this example for you. Hope it helps!
ps: when you have a getValue, you don't need a path;
Thanks @jpedroschmitz
It fits perfectly nice in my needs!