Refactor & clean up code.
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
'use client';
|
||||
|
||||
import { createBrowserClient } from '@supabase/ssr';
|
||||
import type { Database, SupabaseClient } from '@/utils/supabase';
|
||||
import { useMemo } from 'react';
|
||||
import type { Database, SBClientWithDatabase } from '@/utils/supabase';
|
||||
|
||||
let client: SupabaseClient | undefined;
|
||||
let client: SBClientWithDatabase | undefined;
|
||||
|
||||
const getSupbaseClient = (): SupabaseClient | undefined => {
|
||||
const getSupbaseClient = (): SBClientWithDatabase | undefined => {
|
||||
if (client) return client;
|
||||
client = createBrowserClient<Database>(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||
@@ -15,8 +13,6 @@ const getSupbaseClient = (): SupabaseClient | undefined => {
|
||||
return client;
|
||||
};
|
||||
|
||||
const useSupabaseClient = () => {
|
||||
return useMemo(getSupbaseClient, []);
|
||||
};
|
||||
const SupabaseClient = () => getSupbaseClient();
|
||||
|
||||
export { useSupabaseClient };
|
||||
export { SupabaseClient };
|
||||
|
Reference in New Issue
Block a user