Skip to content

Commit

Permalink
Fix memory leak and potential caching issue with usePage (#1366)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessarcher authored Aug 23, 2023
1 parent a572879 commit 6660ede
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions stubs/inertia/resources/js/Components/Banner.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<script setup>
import {ref, watchEffect} from 'vue';
import { ref, watchEffect } from 'vue';
import { usePage } from '@inertiajs/vue3';
const page = usePage();
const show = ref(true);
const style = ref('success');
const message = ref('');
watchEffect(async () => {
style.value = usePage().props.jetstream.flash?.bannerStyle || 'success';
message.value = usePage().props.jetstream.flash?.banner || '';
style.value = page.props.jetstream.flash?.bannerStyle || 'success';
message.value = page.props.jetstream.flash?.banner || '';
show.value = true;
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const props = defineProps({
requiresConfirmation: Boolean,
});
const page = usePage();
const enabling = ref(false);
const confirming = ref(false);
const disabling = ref(false);
Expand All @@ -26,7 +27,7 @@ const confirmationForm = useForm({
});
const twoFactorEnabled = computed(
() => ! enabling.value && usePage().props.auth.user?.two_factor_enabled,
() => ! enabling.value && page.props.auth.user?.two_factor_enabled,
);
watch(twoFactorEnabled, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const props = defineProps({
userPermissions: Object,
});
const page = usePage();
const addTeamMemberForm = useForm({
email: '',
role: null,
Expand Down Expand Up @@ -69,7 +71,7 @@ const confirmLeavingTeam = () => {
};
const leaveTeam = () => {
leaveTeamForm.delete(route('team-members.destroy', [props.team, usePage().props.auth.user]));
leaveTeamForm.delete(route('team-members.destroy', [props.team, page.props.auth.user]));
};
const confirmTeamMemberRemoval = (teamMember) => {
Expand Down

0 comments on commit 6660ede

Please sign in to comment.