airjp73/rvf

[Bug]: (remix) Error when leaving a route with ValidatedForm Ref symbol not found. This is likely a bug in RVF

Closed this issue · 4 comments

Which packages are impacted?

  • @rvf/react
  • @rvf/remix
  • @rvf/zod
  • @rvf/yup
  • zod-form-data

What version of these packages are you using?

"@rvf/remix": "6.1.0",
"@rvf/zod": "6.0.0",

Please provide a link to a minimal reproduction of the issue.

sorry no link yet

Steps to Reproduce the Bug or Issue

This is happening in our remix app.

I haven't fully verified this in our other forms but, navigating to another route when there is rvf managed form in the current route causes this error: Ref symbol not found. This is likely a bug in RVF

What can I do to help you find the cause?

Expected behavior

Not getting the error xD

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome

Additional context

No response

this could be also related to a bug on our side, will investigate

This happens when RVF tries to clean up a ref that's already been cleaned up.

For further context, in React when you do this:

<div ref={element => console.log(element)} />

The behavior is something like this:

  • Component mounts
  • Ref callback gets passed the div element
  • Component unmounts
  • Ref callback gets passed null

AFAIK, React doesn't ever call the same ref callback with null twice in a row. It would always do something like ref(null) then ref(div) then ref(null);

So my thinking is that the issue is one of these three possibilities:

  • You or a component you use is handling some of your refs manually
  • You or a component you use is using useImperativeHandle and providing null as an actual ref value, instead of a cleanup value
  • My understanding of refs needs to be updated lol

It might be safe to ignore this issue when it occurs instead of throwing, but I want to make sure to understand what the issue is before making that call.

thanks for the response. It was indeed not related to rvf. After a recent change, one of our redirects was causing _routes search param (internally added by remix to the requests to its backend) to be included in the url and that was the cause.

Thanks for the update! I'll go ahead and close this for now, then. Please let me know if it turns out to still be an issue.