Я добавляю несколько проверок авторизации на разные страницы приложения, но сталкиваюсь с некоторыми ошибками, передающими часть состояния.
У меня
const RequireAuth = Component => {
return class App extends React.Component {
state = {
isAuthenticated: false,
isLoading: true
};
_updateLogin = () => {
this.setState({ isAuthenticated: true, isLoading: false });
};
render() {
const { isAuthenticated, isLoading } = this.state;
if (isLoading) {
return <div>Placeholder for animation</div>;
}
if (!isAuthenticated) {
return <Redirect to="/auth/login-page" />;
}
return <Component {...this.props} />;
}
};
};
И я пытаюсь передать функцию _updateLogin в компонент AdminLayout, где у меня есть страница входа на
login={this._updateLogin}
возвращается
"Cannot read property '_updateLogin' of undefined.
Любые советы?