convert const function to function

This commit is contained in:
Ren Amamiya
2023-05-10 15:48:24 +07:00
parent ae5ff0c48f
commit 1a30c10806
32 changed files with 87 additions and 79 deletions

View File

@@ -4,7 +4,7 @@ import useSWR from 'swr';
const fetcher = () => getActiveAccount();
export const useActiveAccount = () => {
export function useActiveAccount() {
const { data, error, isLoading } = useSWR('activeAcount', fetcher);
return {
@@ -12,4 +12,4 @@ export const useActiveAccount = () => {
isLoading,
isError: error,
};
};
}

View File

@@ -15,7 +15,7 @@ const fetcher = async ([, id]) => {
}
};
export const useChannelProfile = (id: string, channelPubkey: string) => {
export function useChannelProfile(id: string, channelPubkey: string) {
const pool: any = useContext(RelayContext);
const { data: cache, isLoading } = useSWR(['channel-cache-profile', id], fetcher);
@@ -53,4 +53,4 @@ export const useChannelProfile = (id: string, channelPubkey: string) => {
} else {
return data;
}
};
}

View File

@@ -1,7 +1,7 @@
import { nip04 } from 'nostr-tools';
import { useCallback, useEffect, useState } from 'react';
export const useDecryptMessage = (userKey: string, userPriv: string, data: any) => {
export function useDecryptMessage(userKey: string, userPriv: string, data: any) {
const [content, setContent] = useState(null);
const extractSenderKey = useCallback(() => {
@@ -25,4 +25,4 @@ export const useDecryptMessage = (userKey: string, userPriv: string, data: any)
}, [decrypt]);
return content ? content : null;
};
}

View File

@@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
const getOnLineStatus = () =>
typeof navigator !== 'undefined' && typeof navigator.onLine === 'boolean' ? navigator.onLine : true;
export const useNetworkStatus = () => {
export function useNetworkStatus() {
const [status, setStatus] = useState(getOnLineStatus());
const setOnline = () => setStatus(true);
@@ -20,4 +20,4 @@ export const useNetworkStatus = () => {
}, []);
return status;
};
}

View File

@@ -22,7 +22,7 @@ const fetcher = async (pubkey: string) => {
}
};
export const useProfile = (pubkey: string) => {
export function useProfile(pubkey: string) {
const { data, error, isLoading } = useSWR(pubkey, fetcher);
return {
@@ -30,4 +30,4 @@ export const useProfile = (pubkey: string) => {
isLoading,
isError: error,
};
};
}