如何解决如何找出视场坐标?
有一个包装器功能,用于包装应用程序中的所有字段,输入和表单。填写输入内容时,如果客户输入错误,有时会发生错误。如果存在错误数组,则将第一个数组放入“ firstError”常量中。
现在,如何检查发生错误的字段?如何找出视场坐标?
type ComponentState = {
reference: RefObject<any>;
};
type PropsFromState = {
reference: RefObject<any> | undefined;
formContext: any;
};
export function withScrollToFirstError(Component: t.form.Component): React.ComponentType {
class ScrollToFirstErrorHOC extends PureComponent<PropsFromState,ComponentState> {
constructor(props: PropsFromState) {
super(props);
const ref = this.props.reference;
}
componentDidUpdate(
prevProps: Readonly<PropsFromState>,prevState: Readonly<ComponentState>,snapshot?: any,) {
const errorsArray = this.props.formContext.errors.toArray();
if (!isEmpty(errorsArray)) {
const firstError = errorsArray[0];
}
}
public render() {
return <Component {...this.props} />;
}
}
const mapStateToProps = createStructuredSelector<State,PropsFromState>({
reference: selectReference,formContext: selectFormContext,});
const mapDispatchToProps = {};
return compose<PropsFromState,{}>(
connect(mapStateToProps,mapDispatchToProps),withProps(getPath),withProps(getFieldErrors),withProps(getParamConfig),)(ScrollToFirstErrorHOC);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。