-
-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memoize transform
to fix long standing useForm
bug
#1718
base: master
Are you sure you want to change the base?
Conversation
Merge main project changes
Merge updates from main project
@reinink Any idea when this might be merged? 🙏 |
I need this fix as well! The Repro steps: const myCallback = (data) => {
console.log("myCallback")
return data
}
form.transform(myCallback)
form.post('some/url', { onSuccess: ({ props }) => {
form.setData(props.formData)
form.post('some/url') // "myCallback" is not printed out
}) |
I added a package containing this fix in the npm registry if anyone is interested: |
Yay, thanks! Now what? |
Please forgive me for tagging... @claudiodekker @jessarcher @thecrypticace |
It would sure be great to get this long standing bug fixed. Hoping this is the bump that gets attention. |
I'm opening another PR to fix this bug (#1171, #1131, #1491, #1631)
In the React
useForm
package, thetransform
function is set as a local variable in the component. This means that if the page triggers any re-render, thetransform
variable is re-initialized to the placeholder function ((data) => data
). For this reason, it's more likely than not that the transform method does nothing, rendering the docs inaccurate.The previous PRs were closed without being read. I think the whole React community here would really appreciate this bug finally being fixed.