feat: use JSX.Element as component type

This commit is contained in:
XlebyllleK
2025-01-11 13:50:29 +02:00
committed by GitHub
parent 39cc3065dd
commit a039720a71
16 changed files with 77 additions and 107 deletions

View File

@@ -2,7 +2,12 @@ import { useState, useEffect, useCallback } from 'react';
import { Package } from '../types';
import { fetchPackages } from '../services/api';
export function usePackages() {
export function usePackages(): {
packages: Package[];
loading: boolean;
error: string | null;
retryLoading: () => void;
} {
const [packages, setPackages] = useState<Package[]>([]);
const [loading, setLoading] = useState<boolean>(true);
const [error, setError] = useState<string | null>(null);

View File

@@ -1,8 +1,13 @@
import { useState, useEffect } from 'react';
type Theme = 'light' | 'dark';
import {
Theme
} from '../types';
export function useTheme() {
export function useTheme(): {
theme: Theme;
toggleTheme: () => void;
} {
const getInitialTheme = (): Theme => {
const savedTheme = localStorage.getItem('theme') as Theme;
if (savedTheme === 'dark' || savedTheme === 'light') return savedTheme;