Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewgapp committed Jan 4, 2024
1 parent 5365ff6 commit 549144b
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 549144b

Please sign in to comment.