Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/vikejs/vike-solid into phon…
Browse files Browse the repository at this point in the history
…zammi/feat-vike-solid-query2
  • Loading branch information
phonzammi committed Sep 4, 2024
2 parents 3e5d940 + a31b5c3 commit 3e4f738
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
10 changes: 10 additions & 0 deletions packages/vike-solid/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## [0.7.4](https://github.com/vikejs/vike-solid/compare/v0.7.3...v0.7.4) (2024-09-04)


### Bug Fixes

* add vite as peer dependency (fix [#110](https://github.com/vikejs/vike-solid/issues/110)) ([704e0a7](https://github.com/vikejs/vike-solid/commit/704e0a7ae3dd41e350d0a3f50516e0ebeee6a90d))
* useData lose reactivity ([3fa1f95](https://github.com/vikejs/vike-solid/commit/3fa1f9561a1fa7f8811e67b6b3fb020cc4223955))



## [0.7.3](https://github.com/vikejs/vike-solid/compare/v0.7.2...v0.7.3) (2024-08-24)


Expand Down
13 changes: 12 additions & 1 deletion packages/vike-solid/hooks/useData.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { createStore } from "solid-js/store";

export { useData };

import { createEffect } from "solid-js";
import { usePageContext } from "./usePageContext.js";

/** Access `pageContext.data` from any SolidJS component
Expand All @@ -9,6 +12,14 @@ import { usePageContext } from "./usePageContext.js";
* - https://vike.dev/pageContext-anywhere
*/
function useData<Data>(): Data {
const { data } = usePageContext() as any;
const ctx = usePageContext() as any;

// sub store to keep reactivity https://github.com/vikejs/vike-solid/issues/114
const [data, setData] = createStore(ctx.data);

createEffect(() => {
setData(ctx.data);
});

return data;
}
2 changes: 1 addition & 1 deletion packages/vike-solid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vike-solid",
"version": "0.7.3",
"version": "0.7.4",
"type": "module",
"scripts": {
"dev": "rollup -c rollup.config.js --watch",
Expand Down

0 comments on commit 3e4f738

Please sign in to comment.