App = () => {
console.log('!!!!!!');
const currentUser = storage.getCurrentUser();
if (!currentUser) {
return <Redirect to="/reg" />;
}
return (
<>
<Home />
<Switch>
<Route exact path="/reg" component={RegistrationPage} />
<Route exact path="/auth" component={AuthenticationPage} />
<Route exact path="/" component={Home} />
</Switch>
</>
);
};
init.js
const runApp = () => {
storage.initDataBase();
const store = configureStore({ reducer });
render(
<BrowserRouter>
<Provider store={store}>
<App />
</Provider>
</BrowserRouter>,
document.getElementById('root'),
);
};
index.js
runApp();
Покажи какие либы импортируешь?
APP.js import React from 'react'; import { Switch, Route, Redirect } from 'react-router-dom'; init.js import React from 'react'; import { render } from 'react-dom'; import { BrowserRouter } from 'react-router-dom'; import { Provider } from 'react-redux'; import { configureStore } from '@reduxjs/toolkit';
devServer.historyApiFallback - решило проблему
Обсуждают сегодня