Skip to content

Commit

Permalink
Fix id generation
Browse files Browse the repository at this point in the history
  • Loading branch information
lxsmnsyc committed Oct 25, 2023
1 parent 65a3e42 commit 7a7c2a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions packages/start/islands/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Component, ComponentProps, lazy, sharedConfig } from "solid-js";
import { Component, ComponentProps, createUniqueId, lazy, sharedConfig } from "solid-js";
import { Hydration, NoHydration } from "solid-js/web";
import { useRequest } from "../server/ServerContext";
import { IslandManifest } from "../server/types";
import { splitProps } from "./utils";
export { default as clientOnly } from "./clientOnly";

declare module "solid-js" {
Expand Down Expand Up @@ -66,15 +65,20 @@ export function island<T extends Component<any>>(
return <Component {...props} />;
}

// FIXME Introduce a new ID generation scheme
// for islands
const id = createUniqueId();

sharedConfig.context.serialize(
// TODO how to get the ID?
id,
props,
);


return (
<Hydration>
<solid-island
data-id={id}
data-component={fpath!}
data-island={path}
data-when={(props as any)["client:idle"] ? "idle" : "load"}
Expand Down
4 changes: 2 additions & 2 deletions packages/start/islands/mount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function hydrateServerRouter() {
if (!Component || !el.dataset.hk) return;

let hk = el.dataset.hk;
_$DEBUG("hydrating island", el.dataset.island, hk.slice(0, hk.length - 1) + `1-`, el);
// _$DEBUG("hydrating island", el.dataset.island, hk.slice(0, hk.length - 1) + `1-`, el);

let props = createStore({
...JSON.parse(el.dataset.props!),
Expand All @@ -38,7 +38,7 @@ export function hydrateServerRouter() {
map.set(el, props);

hydrate(() => createComponent(Component, props[0]), el, {
renderId: hk.slice(0, hk.length - 1) + `${1 + Number(el.dataset.offset)}-`,
renderId: el.dataset.id,
owner: lookupOwner(el)
});

Expand Down

0 comments on commit 7a7c2a0

Please sign in to comment.