Skip to content

Commit 808a048

Browse files
committed
use render now check if it is in ssr mode
1 parent b16319e commit 808a048

File tree

4 files changed

+48
-47
lines changed

4 files changed

+48
-47
lines changed

package-lock.json

Lines changed: 38 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@atomico/hooks",
33
"description": "Series of utilities in hooks format to extend the operation of Atomico",
4-
"version": "3.36.2",
4+
"version": "3.37.0",
55
"type": "module",
66
"workspaces": [
77
"src/**/*"
@@ -16,15 +16,15 @@
1616
"access": "public"
1717
},
1818
"peerDependencies": {
19-
"atomico": "^1.45.0"
19+
"atomico": "^1.56.0"
2020
},
2121
"devDependencies": {
2222
"@atomico/exports": "^0.20.0",
2323
"@esm-bundle/chai": "^4.3.4-fix.0",
2424
"@types/chai": "^4.2.21",
2525
"@web/test-runner": "^0.13.16",
2626
"@web/test-runner-commands": "^0.5.12",
27-
"atomico": "^1.45.0",
27+
"atomico": "^1.56.0",
2828
"typescript": "^4.6.2"
2929
}
3030
}

src/use-render/use-render.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { h, render, useHost, useMemo, useEffect } from "atomico";
1+
import { h, useHost, useMemo, useEffect, options } from "atomico";
22

33
const host = h("host");
44
/**
@@ -22,7 +22,10 @@ function fillHost(vdom) {
2222
export function useRender(callback, args) {
2323
const host = useHost();
2424
host.id = host.id || Symbol();
25-
useMemo(() => render(fillHost(callback()), host.current, host.id), args);
25+
useMemo(
26+
() => !options.ssr && fillHost(callback()).render(host.current, host.id),
27+
args
28+
);
2629
// Clean nodes in case of recycling
27-
useEffect(() => () => render(fillHost(), host.current, host.id), []);
30+
useEffect(() => () => fillHost().render(host.current, host.id), []);
2831
}

src/use-render/use-render.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "@esm-bundle/chai";
2-
import html from "atomico/html";
2+
import { html } from "atomico";
33
import { createHooks } from "atomico/test-hooks";
44
import { useRender } from "./use-render.js";
55

0 commit comments

Comments
 (0)