Skip to content

fix(vue-form): losing reactivity #1371

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

teleskop150750
Copy link

@teleskop150750 teleskop150750 commented Apr 3, 2025

close #1503
close #1515
close #1276

Fix of loss of reactivity
Refactor Field: improve granular updates and lazy slot props

@teleskop150750
Copy link
Author

It might be necessary to put the entire api into signal

Link

@teleskop150750 teleskop150750 changed the title refactor(vue-form): sync with solid js fix(vue-form): losing reactivity Apr 6, 2025
@j0rgedev
Copy link

Would it be possible to watch default values key so it can update when it changes? This could be useful when fetching data, instead of creating a lot of computed properties like the example

@teleskop150750
Copy link
Author

Would it be possible to watch default values key so it can update when it changes? This could be useful when fetching data, instead of creating a lot of computed properties like the example

Config changes should be tracked

https://github.com/TanStack/form/pull/1371/files#diff-0a5a2e9d19c33d06bab093ed6ec5baeccdb1d5eb94def19bffd0555c82658597R246-R250

@j0rgedev
Copy link

j0rgedev commented May 9, 2025

Hey @teleskop150750. Do you have any workaround until this is merged? I think it hasn't been reviewed yet since the main issue was closed

@j0rgedev
Copy link

Created the issue #1503 to track this PR 👍🏻

@LeCarbonator
Copy link
Contributor

It's great to have the explanation listed in the linked issue, but even with a perfect PR, this is a breaking change. It would be delayed until a v2 release.

This also appears to be a (major) improvement on Vue's current reactivity system rather than 'fixing' a loss of reactivity. Please correct me if I'm wrong.

@teleskop150750
Copy link
Author

teleskop150750 commented Jul 15, 2025

It's great to have the explanation listed in the linked issue, but even with a perfect PR, this is a breaking change. It would be delayed until a v2 release.

This also appears to be a (major) improvement on Vue's current reactivity system rather than 'fixing' a loss of reactivity. Please correct me if I'm wrong.

The implementation is synchronized with the solidjs version. In signal-based frameworks, it is necessary to pass reactive data in callbacks. There are other workarounds, such as a getter object field or proxy. But they are more complex and inconvenient.

For some reason, SolidJs makes such mistakes less often and passes parameters correctly. In Vue, this causes difficulties every time because Ref is confusing

vuejs/rfcs#747

@teleskop150750
Copy link
Author

teleskop150750 commented Jul 15, 2025

The current implementation of Vue lacks wathEffect for parameters. So updating parameters does not update the state.

UPD:

@teleskop150750
Copy link
Author

You can try to rewrite the PR to keep the API. I wanted to bring it closer to SolidJs in advance because it is more flexible and less likely to be subject to changes in the future.

@LeCarbonator
Copy link
Contributor

The current implementation of Vue lacks withEffect for parameters. So updating parameters does not update the state.

Can you elaborate on this? Can that be fixed with the current API until v2 (maybe) migrates to this signal-based one?

@teleskop150750
Copy link
Author

Solif js Update FormApi

VueJS No dependency tracking

example fix

https://vuejs.org/api/reactivity-utilities.html#tovalue

function useForm(opts?: MaybeRefOrGetter<Options>) {
  const api = new FormApi(opts?.()) 
  let isMouned = false

  watchEffect(() => {
     const optsVal = toValue(opts)
     if (isMouned) {
       api.update(optsVal)
     }
  })
  
  onMounted(() => {
    isMouned = true
    formApi.mount()
  })
}

@teleskop150750
Copy link
Author

I made additional edits to FormField. I don't remember the exact reason. I think it was to reduce the number of updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix(vue-form): losing reactivity Please fix the implementation in vue
3 participants