UNPKG

@fruits-chain/react-native-xiaoshu

Version:
32 lines (28 loc) 1.09 kB
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import React, { useImperativeHandle, forwardRef } from 'react'; import RCForm from 'rc-field-form'; import Toast from '../toast'; import useForm from './useForm'; /** * 默认处理错误的回调 */ const defaultOnFinishFailed = errorInfo => { Toast(errorInfo.errorFields[0].errors[0]); }; const InternalForm = (_ref, ref) => { let { onFinishFailed = defaultOnFinishFailed, form, ...restProps } = _ref; const [wrapForm] = useForm(form); useImperativeHandle(ref, () => wrapForm); return /*#__PURE__*/React.createElement(RCForm, _extends({}, restProps, { component: false, form: wrapForm, onFinishFailed: onFinishFailed })); }; const Form = /*#__PURE__*/forwardRef(InternalForm); export default Form; //# sourceMappingURL=form.js.map