Closed pdanpdan closed 3 weeks ago
A fix for pageContextReactive
is still needed (in changePage
)
I think I found a use case where this unfortunately doesn't work. Let me try to reproduce on /examples/full/
.
BTW, if we want to treat data
as readonly we could go with shallowRef
I'll try after we check possible breaking case(s)
https://github.com/vikejs/vike-vue/commit/984ef6073e61f09a0d8f4598d762815ddc9f5ce2 breaks this PR.
To reproduce:
cd examples/full/
pnpm run dev
Observe text: "Hi anonymous."
/hello/eli
.
Observe text is still:
Hi anonymous.
.
(It should beHi eli.
.)
Observe text is now:
Hi eli.
.
It looks like we need to return the full ref, so the DX changes in JS/TS (stays the same in template)
in order to keep reactivity we need to expose the shallowref
Maybe a hack would be:
const dataRef = ref(data)
Object.assign(dataRef, data)
Not sure if it's worth it. I don't know whether data.value.product.id
is a weird DX for Vue users.
I don't know whether data.value.product.id is a weird DX for Vue users.
Not weird DX, especially if editor interprets TS types you get full autocomplete
Maybe a hack would be: ...
I'm not sure where would that fit
Ok :+1:
On my side I think we should go for this shallowRef()
solution then.
Thoughts on pageContext
? In principle, it should also just be a shallowRef()
I think. But what about the DX :thinking:
I'll clean up this PR and let's move to another issue for pageContext
:+1: And let's also decide about pageContext
before merging. Probably best to holistically decide for both.
Cleanup done here and opened sibling issue https://github.com/vikejs/vike-vue/issues/121
This should be now ready
I made some minor changes, let me know if you disagree with something. Otherwise I'll squash, merge, and release.
LGTM
Merged :tada:
Thank you the neat collaboration :green_heart:
And released as 0.7.2
:rocket:
@4350pChris I went ahead without your input because this PR fixes a couple of bugs without introducing any (conceptual) breaking change. But I'm more than happy to have the conversation whether we should go for shallowRef()
instead of shallowReactive()
(or something entirely else) with you — in case you disagree with some of the discussions we had at https://github.com/vikejs/vike-vue/issues/116 and https://github.com/vikejs/vike-vue/issues/121.
BREAKING CHANGE: data from
+data
hook must be a non-array object (if you need to return a list wrap it in an object) BREAKING CHANGE: bothuseData
andusePageContext
returnshallowReactive
instead ofreactive
closes #116, closes #121