mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-18 03:14:07 +08:00
type: add generics to AppProps (#45669)
* type: add generics to AppProps * type: add generics to rootProps
This commit is contained in:
parent
fe59bb054d
commit
d1ed46938b
@ -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,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user