Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewgapp committed Jan 5, 2024
1 parent b87b359 commit 3c2b58d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/sqlsync-solid-js/src/context.tsx
Original file line number Diff line number Diff line change
@@ -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]>([
Expand All @@ -20,12 +19,11 @@ export const createSqlSync = (props: Props): SQLSync => {
export const SQLSyncProvider: ParentComponent<Props> = (props) => {
const [sqlSync, setSQLSync] = createSignal<SQLSync>(createSqlSync(props));

createEffect(() => {
const sqlSync = createSqlSync(props);
setSQLSync(sqlSync);
onCleanup(() => {
sqlSync.close();
});
onCleanup(() => {
const s = sqlSync();
if (s) {
s.close();
}
});

return (
Expand Down

0 comments on commit 3c2b58d

Please sign in to comment.