How I can fix my router? I am using redux to handle logout but when logout, it will direct me to 404 page then to login page. I tried to put exact
to the routes and made the 404 route last in the list of the routes. My website has different user roles so I think the bug is related to that.
<Routes>
<Route path={ROUTES.Error} element={<NotFound />} />
<Route path={ROUTES.home} element={<Private />}>
{pages
.filter((page) =>
page.hasAccess.some((role) =>
_.isEqual(role, user?.info?.RoleCode),
),
)
.map(({ id, path, element: Element }) => (
<>
<Route
key={id}
path={ROUTES.home}
element={<Navigate replace to="dashboard" />}
/>,
<Route key={id} path={path} element={<Element />} />
</>
))}
</Route>
<Route
path=""
element={<Public />}
children={<Route path={ROUTES.login} element={<Login />} />}
/>
</Routes>
Under saga Logout
function* logout() {
yield put(userSlice.actions.logoutFulfilled(null));
socket.disconnect();
yield new Promise(() => {
notification.success({
message: 'Success',
description: 'Logout Success',
});
});
}