1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Update to React 18

This commit is contained in:
grafixeyehero 2024-06-02 20:58:11 +03:00
parent b5d6e37fb3
commit be891c3a98
36 changed files with 339 additions and 311 deletions

View file

@ -1,7 +1,7 @@
import type { Api } from '@jellyfin/sdk';
import type { UserDto } from '@jellyfin/sdk/lib/generated-client';
import type { ApiClient, Event } from 'jellyfin-apiclient';
import React, { createContext, FC, useContext, useEffect, useMemo, useState } from 'react';
import React, { type FC, type PropsWithChildren, createContext, useContext, useEffect, useMemo, useState } from 'react';
import ServerConnections from '../components/ServerConnections';
import events from '../utils/events';
@ -16,7 +16,7 @@ export interface JellyfinApiContext {
export const ApiContext = createContext<JellyfinApiContext>({});
export const useApi = () => useContext(ApiContext);
export const ApiProvider: FC = ({ children }) => {
export const ApiProvider: FC<PropsWithChildren<unknown>> = ({ children }) => {
const [ legacyApiClient, setLegacyApiClient ] = useState<ApiClient>();
const [ api, setApi ] = useState<Api>();
const [ user, setUser ] = useState<UserDto>();

View file

@ -1,7 +1,7 @@
import { useCallback, useEffect, useState } from 'react';
import { currentSettings as userSettings } from 'scripts/settings/userSettings';
import Events from 'utils/events';
import Events, { type Event } from 'utils/events';
import { useApi } from './useApi';
import { useThemes } from './useThemes';
@ -30,7 +30,7 @@ export function useUserTheme() {
if (userDashboardTheme) setDashboardTheme(userDashboardTheme);
}, []);
const onUserSettingsChange = useCallback((_e, name?: string) => {
const onUserSettingsChange = useCallback((_e: Event, name?: string) => {
if (name && THEME_FIELD_NAMES.includes(name)) {
updateThemesFromSettings();
}

View file

@ -1,4 +1,4 @@
import React, { createContext, FC, useContext, useEffect, useState } from 'react';
import React, { type FC, type PropsWithChildren, createContext, useContext, useEffect, useState } from 'react';
import type { WebConfig } from '../types/webConfig';
import defaultConfig from '../config.json';
@ -7,7 +7,7 @@ import fetchLocal from '../utils/fetchLocal';
export const WebConfigContext = createContext<WebConfig>(defaultConfig);
export const useWebConfig = () => useContext(WebConfigContext);
export const WebConfigProvider: FC = ({ children }) => {
export const WebConfigProvider: FC<PropsWithChildren<unknown>> = ({ children }) => {
const [ config, setConfig ] = useState<WebConfig>(defaultConfig);
useEffect(() => {