Доброго времени суток друзья, на странице возникает ошибка: Cannot read property objectWithSizes of null. Она возникает только на определенной странице, на всех остальных работает номрально. В чем может быть проблема?
type ComponentState = {
objectWithSizes?: {
height?: number,
offset?: number,
id?: string
};
};
export function withScrollToFirstError(Component: t.form.Component): React.ComponentType {
class ScrollToFirstErrorHOC extends PureComponent<OuterProps & PropsFromState, ComponentState> {
componentDidUpdate() {
const { arrayOfSizes, firstFieldId, currentFieldId, firstError } = this.props;
this.pushToArray(currentFieldId, firstFieldId, arrayOfSizes);
}
pushToArray = (currentFieldId: string, firstFieldId: string, arrayOfSizes: Array<any>) => {
if (currentFieldId === firstFieldId) {
arrayOfSizes.splice(0, arrayOfSizes.length);
}
arrayOfSizes.push(this.state.objectWithSizes);
};
public render() {
return (
<View
onLayout={({ nativeEvent: { layout } }) => {
this.setState({
objectWithSizes: {
height: layout.height,
offset: layout.y,
id: this.props.currentFieldId,
},
});
}}
>
<Component {...this.props} />
</View>
);
}
}