now everything works with React ToolKit
This commit is contained in:
+13
-4
@@ -16,7 +16,6 @@ import Posts from './components/posts/Posts';
|
||||
import Post from './components/post/Post';
|
||||
import NotFound from './components/layout/NotFound';
|
||||
import PrivateRoute from './components/routing/PrivateRoute';
|
||||
import { LOGOUT } from './actions/types';
|
||||
|
||||
// Redux
|
||||
import { Provider } from 'react-redux';
|
||||
@@ -25,6 +24,7 @@ import { loadUser } from './actions/auth';
|
||||
import setAuthToken from './utils/setAuthToken';
|
||||
|
||||
import './App.css';
|
||||
import { logOut } from './reducers/auth';
|
||||
|
||||
// Level - 1
|
||||
//
|
||||
@@ -42,13 +42,12 @@ const App = () => {
|
||||
|
||||
// log user out from all tabs if they log out in one tab
|
||||
window.addEventListener("storage", () => {
|
||||
if (!localStorage.token) store.dispatch({ type: LOGOUT });
|
||||
if (!localStorage.token) store.dispatch(logOut);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Provider store={store}>
|
||||
// Seting Up redux store
|
||||
<Provider store={store}>
|
||||
<Router>
|
||||
<Navbar />
|
||||
<Alert />
|
||||
@@ -85,6 +84,16 @@ const App = () => {
|
||||
</Router>
|
||||
</Provider>
|
||||
);
|
||||
/*
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<Router>
|
||||
<Routes>
|
||||
<Route path="login" element={<Login />} />
|
||||
</Routes>
|
||||
</Router>
|
||||
</Provider>
|
||||
);*/
|
||||
};
|
||||
|
||||
export default App;
|
||||
|
||||
Reference in New Issue
Block a user