Skip to content

Commit

Permalink
Fix early dispose for createLazyMemo
Browse files Browse the repository at this point in the history
  • Loading branch information
lxsmnsyc committed Sep 22, 2022
1 parent 953925a commit e7d022c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/solid-styled/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ interface CSSVars {

function createLazyMemo<T>(fn: () => T): () => T {
let s: () => T;
let dispose: () => void | undefined;
onCleanup(() => dispose());
let dispose: (() => void) | undefined;
onCleanup(() => dispose?.());
return () => {
if (!s) {
s = createRoot((d) => {
Expand Down Expand Up @@ -135,9 +135,9 @@ export function createCSSVars(): CSSVars {

function serializeStyle(source: JSX.CSSProperties): string {
let result = '';
Object.keys(source).forEach((key) => {
result = `${result}${key}:${String(source[key])};`;
});
for (const key of Object.keys(source)) {
result = `${result}${key}:${String(source[key as keyof JSX.CSSProperties])};`;
}
return result;
}

Expand Down

0 comments on commit e7d022c

Please sign in to comment.