下午好朋友们。我有两个问题。
中声明类似于"const {}= this.props“的内容。
export function withScrollToFirstError(Component: t.form.Component): React.ComponentType {
class ScrollToFirstErrorHOC extends PureComponent<OuterProps & PropsFromState, ComponentState> {
constructor(props: OuterProps & PropsFromState) {
super(props);
this.state = {
height: 0,
offset: 0,
};
}
componentDidUpdate() {
this.existError();
}
existError = () => {
const { currentFieldId, firstFieldId, arrayOfHeight, fieldOffset, fieldErrors } = this.props;
this.calculateCoordinate();
};
calculateCoordinate = () => {
const fullOffset = offset + fieldOffset[0];
this.scrollToRef();
};
scrollToRef = () => {
if (this.props.reference) {
this.props.reference.current.scrollTo({
x: 0,
y: 0,
animated: true,
});
}
};
发布于 2020-11-12 11:01:01
将Fulloffset传递给scrollToRef
calculateCoordinate = () => {
const fullOffset = offset + fieldOffset[0];
this.scrollToRef(fullOffset); // like this
};
scrollToRef = (fullOffset) => {
if (this.props.reference) {
this.props.reference.current.scrollTo({
x: 0,
y: 0,
animated: true,
});
}
};全球宣布道具
export function withScrollToFirstError(Component: t.form.Component): React.ComponentType {
class ScrollToFirstErrorHOC extends PureComponent<OuterProps & PropsFromState, ComponentState> {
constructor(props: OuterProps & PropsFromState) {
super(props);
this.state = {
height: 0,
offset: 0,
};
// initialize here
this.arrayOfHeight = props.arrayOfHeight;
}
componentDidUpdate() {
this.existError();
}
existError = () => {
// use here like
this.arrayOfHeight;
};
}https://stackoverflow.com/questions/64802423
复制相似问题