From 3c2b58d026d337564be647ee5c2298209a27307a Mon Sep 17 00:00:00 2001 From: Matthew Gapp <61894094+matthewgapp@users.noreply.github.com> Date: Wed, 3 Jan 2024 19:30:25 -0800 Subject: [PATCH] fix --- lib/sqlsync-solid-js/src/context.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/sqlsync-solid-js/src/context.tsx b/lib/sqlsync-solid-js/src/context.tsx index 1c7aa6b..06675e0 100644 --- a/lib/sqlsync-solid-js/src/context.tsx +++ b/lib/sqlsync-solid-js/src/context.tsx @@ -1,5 +1,4 @@ -// import { ReactNode, createContext, useEffect, useState } from "react"; -import { ParentComponent, createContext, createEffect, createSignal, onCleanup } from "solid-js"; +import { ParentComponent, createContext, createSignal, onCleanup } from "solid-js"; import { SQLSync } from "./sqlsync"; export const SQLSyncContext = createContext<[() => SQLSync | null, (sqlSync: SQLSync) => void]>([ @@ -20,12 +19,11 @@ export const createSqlSync = (props: Props): SQLSync => { export const SQLSyncProvider: ParentComponent = (props) => { const [sqlSync, setSQLSync] = createSignal(createSqlSync(props)); - createEffect(() => { - const sqlSync = createSqlSync(props); - setSQLSync(sqlSync); - onCleanup(() => { - sqlSync.close(); - }); + onCleanup(() => { + const s = sqlSync(); + if (s) { + s.close(); + } }); return (