mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-11 23:00:20 +08:00
849dd97456
* fix(form): fix `useFormItemStatus` get access to window error when sever-side-rendering * fix(form): use official doc in `useFormItemStatus` fix(form): replace the string literal by official doc in `useFormItemStatus` warning message. * fix(form): use official doc in warning - Remove unnecessary client check - Use official i18n doc href.
26 lines
759 B
TypeScript
26 lines
759 B
TypeScript
import { useContext } from 'react';
|
|
import type { ValidateStatus } from 'antd/es/form/FormItem';
|
|
import { FormItemInputContext } from '../context';
|
|
import warning from '../../_util/warning';
|
|
|
|
type UseFormItemStatus = () => {
|
|
status?: ValidateStatus;
|
|
};
|
|
|
|
const useFormItemStatus: UseFormItemStatus = () => {
|
|
const { status } = useContext(FormItemInputContext);
|
|
|
|
warning(
|
|
status !== undefined,
|
|
'Form.Item',
|
|
'Form.Item.useStatus should be used under Form.Item component. For more information: https://u.ant.design/form-item-usestatus',
|
|
);
|
|
|
|
return { status };
|
|
};
|
|
|
|
// Only used for compatible package. Not promise this will work on future version.
|
|
(useFormItemStatus as any).Context = FormItemInputContext;
|
|
|
|
export default useFormItemStatus;
|