Use source loader for email sprite icons
[ProtonMail-WebClient.git] / packages / wallet / store / hooks / useNetworkFees.ts
blob65eb80c0c708626fc11816929a12ff3dafffbc51
1 import { useEffect } from 'react';
3 import { createSelector } from '@reduxjs/toolkit';
5 import { baseUseSelector } from '@proton/react-redux-store';
6 import { createHooks } from '@proton/redux-utilities';
8 import { type FeeSettings, networkFeesThunk, selectNetworkFees } from '../slices';
10 const hooks = createHooks(networkFeesThunk, selectNetworkFees);
12 export const useGetNetworkFees = hooks.useGet;
14 export const useNetworkFees = () => {
15     const getNetworkFees = useGetNetworkFees();
16     const [, loading] = hooks.useValue();
18     const networkFeesSelector = createSelector(selectNetworkFees, (result): [FeeSettings | undefined, boolean] => {
19         const { value } = result;
21         return [value, loading];
22     });
24     useEffect(() => {
25         void getNetworkFees();
26     }, []);
28     return baseUseSelector(networkFeesSelector);