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

Fix usePage() reactivity in Vue 2 adapter #1527

Merged
merged 2 commits into from
Apr 20, 2023
Merged

Conversation

reinink
Copy link
Member

@reinink reinink commented Apr 20, 2023

Right now the usePage() hook in the Vue 2 adapter isn't actually reactive. The following doesn't work:

<script setup>
import { usePage } from '@inertiajs/vue2'
import { computed } from 'vue'

const page = usePage()

const appName = computed(() => page.props.appName)
</script>

This PR updates the Vue 2 adapter to use the same technique used in the Vue 3 adapter to solve this (see #1469).

The only issue here is that this requires Vue 2.7 features to fix this — the computed() and reactive() methods. Meaning anyone who is still using Vue 2.6 will need to also upgrade to Vue 2.7 when updating to the next release of Inertia. Given that this is the only way to solve this problem, I think that's a reasonable tradeoff.

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.

1 participant