capacitor-community / react-hooks

⚡️ React hooks for Capacitor ⚡️
Other
246 stars 22 forks source link

Why does useFilesystem Exists? #53

Open hheimerd opened 1 year ago

hheimerd commented 1 year ago

Why do I need this hook? Why are you not satisfied with accessing these functions directly? All functions from this hook are static and have no initialization stage, functions have no state, available features do not change. These are literally static functions wrapped in useCallback, which are already memoized and never change.

And this is the only hook that is described in the documentation

hheimerd commented 1 year ago

I have come up with a new hook for you, you can use. If necessary, I can make a pull request.

type RoundOptions = number

type MathResult = {
    random(): number,
    round(options: RoundOptions): number,
    isAvailable: boolean
}

export function useMath(): MathResult {
    const random = useCallback(() => {
        const result = Math.random();
        return result;
    }, []);

    const round = useCallback((options: RoundOptions) => {
        const result = Math.round(options);
        return result;
    }, []);

    return {
        random,
        round,
        isAvailable: true,
    };
}
oliveryasuna commented 11 months ago

This is rude and should be closed.