type: add generics to AppProps (#45669)

* type: add generics to AppProps

* type: add generics to rootProps
This commit is contained in:
Jex 2023-11-04 01:35:40 +08:00 committed by GitHub
parent fe59bb054d
commit d1ed46938b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@ import type { ReactNode } from 'react';
import React, { useContext } from 'react';
import classNames from 'classnames';
import type { CustomComponent } from '../_util/type';
import type { AnyObject, CustomComponent } from '../_util/type';
import type { ConfigConsumerProps } from '../config-provider';
import { ConfigContext } from '../config-provider';
import useMessage from '../message/useMessage';
@ -12,18 +12,18 @@ import type { AppConfig, useAppProps } from './context';
import AppContext, { AppConfigContext } from './context';
import useStyle from './style';
export interface AppProps extends AppConfig {
export interface AppProps<P = AnyObject> extends AppConfig {
style?: React.CSSProperties;
className?: string;
rootClassName?: string;
prefixCls?: string;
children?: ReactNode;
component?: false | CustomComponent;
component?: CustomComponent<P> | false;
}
const useApp = () => React.useContext<useAppProps>(AppContext);
const App: React.FC<AppProps> & { useApp: typeof useApp } = (props) => {
const App: React.FC<AppProps> & { useApp: () => useAppProps } = (props) => {
const {
prefixCls: customizePrefixCls,
children,
@ -66,7 +66,7 @@ const App: React.FC<AppProps> & { useApp: typeof useApp } = (props) => {
// ============================ Render ============================
const Component = component === false ? React.Fragment : component;
const rootProps = {
const rootProps: AppProps = {
className: customClassName,
style,
};