mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-18 11:18:14 +08:00
chore(import): ensure code convention compliance by importing React (#52021)
Some checks failed
Publish Any Commit / build (push) Waiting to run
🔀 Sync mirror to Gitee / mirror (push) Waiting to run
✅ test / lint (push) Waiting to run
✅ test / test-react-legacy (16, 1/2) (push) Waiting to run
✅ test / test-react-legacy (16, 2/2) (push) Waiting to run
✅ test / test-react-legacy (17, 1/2) (push) Waiting to run
✅ test / test-react-legacy (17, 2/2) (push) Waiting to run
✅ test / test-node (push) Waiting to run
✅ test / test-react-latest (dom, 1/2) (push) Waiting to run
✅ test / test-react-latest (dom, 2/2) (push) Waiting to run
✅ test / test-react-latest-dist (dist, 1/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist, 2/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist-min, 1/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist-min, 2/2) (push) Blocked by required conditions
✅ test / test-coverage (push) Blocked by required conditions
✅ test / build (push) Waiting to run
✅ test / test lib/es module (es, 1/2) (push) Waiting to run
✅ test / test lib/es module (es, 2/2) (push) Waiting to run
✅ test / test lib/es module (lib, 1/2) (push) Waiting to run
✅ test / test lib/es module (lib, 2/2) (push) Waiting to run
👁️ Visual Regression Persist Start / test image (push) Waiting to run
Issue Check Inactive / issue-check-inactive (push) Has been cancelled
Some checks failed
Publish Any Commit / build (push) Waiting to run
🔀 Sync mirror to Gitee / mirror (push) Waiting to run
✅ test / lint (push) Waiting to run
✅ test / test-react-legacy (16, 1/2) (push) Waiting to run
✅ test / test-react-legacy (16, 2/2) (push) Waiting to run
✅ test / test-react-legacy (17, 1/2) (push) Waiting to run
✅ test / test-react-legacy (17, 2/2) (push) Waiting to run
✅ test / test-node (push) Waiting to run
✅ test / test-react-latest (dom, 1/2) (push) Waiting to run
✅ test / test-react-latest (dom, 2/2) (push) Waiting to run
✅ test / test-react-latest-dist (dist, 1/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist, 2/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist-min, 1/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist-min, 2/2) (push) Blocked by required conditions
✅ test / test-coverage (push) Blocked by required conditions
✅ test / build (push) Waiting to run
✅ test / test lib/es module (es, 1/2) (push) Waiting to run
✅ test / test lib/es module (es, 2/2) (push) Waiting to run
✅ test / test lib/es module (lib, 1/2) (push) Waiting to run
✅ test / test lib/es module (lib, 2/2) (push) Waiting to run
👁️ Visual Regression Persist Start / test image (push) Waiting to run
Issue Check Inactive / issue-check-inactive (push) Has been cancelled
* fix(import): ensure code convention compliance by importing React * fix(type): add generic type for useMemo
This commit is contained in:
parent
d468a450b0
commit
93ec292961
@ -1,5 +1,4 @@
|
||||
import * as React from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import type { CSSMotionProps } from 'rc-motion';
|
||||
import CSSMotion, { CSSMotionList } from 'rc-motion';
|
||||
@ -58,7 +57,10 @@ const ErrorList: React.FC<ErrorListProps> = ({
|
||||
const rootCls = useCSSVarCls(prefixCls);
|
||||
const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls, rootCls);
|
||||
|
||||
const collapseMotion: CSSMotionProps = useMemo(() => initCollapseMotion(prefixCls), [prefixCls]);
|
||||
const collapseMotion = React.useMemo<CSSMotionProps>(
|
||||
() => initCollapseMotion(prefixCls),
|
||||
[prefixCls],
|
||||
);
|
||||
|
||||
// We have to debounce here again since somewhere use ErrorList directly still need no shaking
|
||||
// ref: https://github.com/ant-design/ant-design/issues/36336
|
||||
|
@ -1,5 +1,4 @@
|
||||
import * as React from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import FieldForm, { List, useWatch } from 'rc-field-form';
|
||||
import type { FormProps as RcFormProps } from 'rc-field-form/lib/Form';
|
||||
@ -93,7 +92,7 @@ const InternalForm: React.ForwardRefRenderFunction<FormRef, FormProps> = (props,
|
||||
useFormWarning(props);
|
||||
}
|
||||
|
||||
const mergedRequiredMark = useMemo(() => {
|
||||
const mergedRequiredMark = React.useMemo(() => {
|
||||
if (requiredMark !== undefined) {
|
||||
return requiredMark;
|
||||
}
|
||||
@ -137,7 +136,7 @@ const InternalForm: React.ForwardRefRenderFunction<FormRef, FormProps> = (props,
|
||||
const { __INTERNAL__ } = wrapForm;
|
||||
__INTERNAL__.name = name;
|
||||
|
||||
const formContextValue = useMemo<FormContextProps>(
|
||||
const formContextValue = React.useMemo<FormContextProps>(
|
||||
() => ({
|
||||
name,
|
||||
labelAlign,
|
||||
|
@ -1,6 +1,5 @@
|
||||
import type { PropsWithChildren, ReactNode } from 'react';
|
||||
import * as React from 'react';
|
||||
import { createContext, useContext, useMemo } from 'react';
|
||||
import { FormProvider as RcFormProvider } from 'rc-field-form';
|
||||
import type { FormProviderProps as RcFormProviderProps } from 'rc-field-form/lib/FormContext';
|
||||
import type { Meta } from 'rc-field-form/lib/interface';
|
||||
@ -78,9 +77,9 @@ export type NoFormStyleProps = PropsWithChildren<{
|
||||
}>;
|
||||
|
||||
export const NoFormStyle: React.FC<NoFormStyleProps> = ({ children, status, override }) => {
|
||||
const formItemInputContext = useContext(FormItemInputContext);
|
||||
const formItemInputContext = React.useContext(FormItemInputContext);
|
||||
|
||||
const newFormItemInputContext = useMemo(() => {
|
||||
const newFormItemInputContext = React.useMemo(() => {
|
||||
const newContext = { ...formItemInputContext };
|
||||
if (override) {
|
||||
delete newContext.isFormItemInput;
|
||||
@ -100,4 +99,4 @@ export const NoFormStyle: React.FC<NoFormStyleProps> = ({ children, status, over
|
||||
);
|
||||
};
|
||||
|
||||
export const VariantContext = createContext<Variant | undefined>(undefined);
|
||||
export const VariantContext = React.createContext<Variant | undefined>(undefined);
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { useContext } from 'react';
|
||||
import * as React from 'react';
|
||||
|
||||
import { FormContext } from '../context';
|
||||
import type { FormInstance } from './useForm';
|
||||
|
||||
export default function useFormInstance<Value = any>(): FormInstance<Value> {
|
||||
const { form } = useContext(FormContext);
|
||||
const { form } = React.useContext(FormContext);
|
||||
|
||||
return form!;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useContext } from 'react';
|
||||
import * as React from 'react';
|
||||
import type { ValidateStatus } from 'antd/es/form/FormItem';
|
||||
|
||||
import { devUseWarning } from '../../_util/warning';
|
||||
@ -11,7 +11,7 @@ type UseFormItemStatus = () => {
|
||||
};
|
||||
|
||||
const useFormItemStatus: UseFormItemStatus = () => {
|
||||
const { status, errors = [], warnings = [] } = useContext(FormItemInputContext);
|
||||
const { status, errors = [], warnings = [] } = React.useContext(FormItemInputContext);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const warning = devUseWarning('Form.Item');
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useEffect } from 'react';
|
||||
import * as React from 'react';
|
||||
|
||||
import { devUseWarning } from '../../_util/warning';
|
||||
import type { FormProps } from '../Form';
|
||||
@ -8,7 +8,7 @@ const names: Record<string, number> = {};
|
||||
export default function useFormWarning({ name }: FormProps) {
|
||||
const warning = devUseWarning('Form');
|
||||
|
||||
useEffect(() => {
|
||||
React.useEffect(() => {
|
||||
if (name) {
|
||||
names[name] = (names[name] || 0) + 1;
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
import * as React from 'react';
|
||||
import { useRef } from 'react';
|
||||
import raf from 'rc-util/lib/raf';
|
||||
|
||||
type Updater<ValueType> = (prev?: ValueType) => ValueType;
|
||||
@ -8,9 +7,9 @@ export default function useFrameState<ValueType>(
|
||||
defaultValue: ValueType,
|
||||
): [ValueType, (updater: Updater<ValueType>) => void] {
|
||||
const [value, setValue] = React.useState(defaultValue);
|
||||
const frameRef = useRef<number | null>(null);
|
||||
const batchRef = useRef<Updater<ValueType>[]>([]);
|
||||
const destroyRef = useRef(false);
|
||||
const frameRef = React.useRef<number | null>(null);
|
||||
const batchRef = React.useRef<Updater<ValueType>[]>([]);
|
||||
const destroyRef = React.useRef(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
destroyRef.current = false;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useContext } from 'react';
|
||||
import * as React from 'react';
|
||||
|
||||
import { VariantContext } from '../context';
|
||||
import type { Variant, ConfigProviderProps } from '../../config-provider';
|
||||
@ -26,8 +26,8 @@ const useVariant = (
|
||||
variant: Variant | undefined,
|
||||
legacyBordered: boolean | undefined = undefined,
|
||||
): [Variant, boolean] => {
|
||||
const { variant: configVariant, [component]: componentConfig } = useContext(ConfigContext);
|
||||
const ctxVariant = useContext(VariantContext);
|
||||
const { variant: configVariant, [component]: componentConfig } = React.useContext(ConfigContext);
|
||||
const ctxVariant = React.useContext(VariantContext);
|
||||
const configComponentVariant = componentConfig?.variant;
|
||||
|
||||
let mergedVariant: Variant;
|
||||
|
Loading…
Reference in New Issue
Block a user