Skip to content
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

[v2.0.0] <Link> component not reactive #2148

Open
renekragelundpedersen opened this issue Dec 20, 2024 · 0 comments
Open

[v2.0.0] <Link> component not reactive #2148

renekragelundpedersen opened this issue Dec 20, 2024 · 0 comments

Comments

@renekragelundpedersen
Copy link

Version:

  • @inertiajs/vue3 version: 2.0.0

Describe the problem:

When parsing :data to the <Link> component, the reactiveness of the data stops, and is not updating inside the component.

Steps to reproduce:

I have this setup:

const note = ref('');
.....
{{ note }}
<textarea v-model="note"/>
.....
<Link
    method="post"
    as="button"
    :href="route('notes.store')"
    :data="{ 'note': note }"
>
    Create
</Link>

Changing the content of the textarea updates the output of {{ note }} correctly, but the :data never updates accordingly.

Using Inertia 1.3.0 all works as expected, and the Request for the endpoint behind 'notes.store' returns:

array:1 [▼ // app/Http/Controllers/NoteController.php:61
  "note" => "testing"
]

Upgrading to Inertia 2.0, the value of 'note' is always the initial value, which is '' (empty string).

Same request:
array:1 [▼ // app/Http/Controllers/NoteController.php:61
  "note" => ""
]

Now if i change the default value inside the ref, to:
const note = ref('foo');

"foo" is posted:
array:1 [▼ // app/Http/Controllers/NoteController.php:61
  "note" => "foo"
]

So it seems that it never updates / binds the changes to the reference.
I've tested by changing it directly with code before submitting, but none of the changes is registered in the :data part of the component.

I can of course also hardcoded a value to the :data part, which also works.

This might be the cause, as it might loose reactivity:
https://github.com/inertiajs/inertia/blob/master/packages/vue3/src/link.ts#L188

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

No branches or pull requests

1 participant