Fixed pages rerendering on sidebar state change
This commit is contained in:
1 parent
aca350495a
commit
111501156f
4 files changed
+7
-5
No files matched your search
+1
-1
@@ -39,7 +39,7 @@ function App() {
|
|||||||
const PageSpeedWithAdminProp = withAdminProp(PageSpeed);
|
const PageSpeedWithAdminProp = withAdminProp(PageSpeed);
|
||||||
const MaintenanceWithAdminProp = withAdminProp(Maintenance);
|
const MaintenanceWithAdminProp = withAdminProp(Maintenance);
|
||||||
|
|
||||||
const { mode } = useSelector((state) => state.ui);
|
const mode = useSelector((state) => state.ui.mode);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeProvider theme={mode === "light" ? theme : darkTheme}>
|
<ThemeProvider theme={mode === "light" ? theme : darkTheme}>
|
||||||
|
|||||||
@@ -86,8 +86,7 @@ function Sidebar() {
|
|||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const authState = useSelector((state) => state.auth);
|
const authState = useSelector((state) => state.auth);
|
||||||
const { sidebar } = useSelector((state) => state.ui);
|
const collapsed = useSelector((state) => state.ui.sidebar.collapsed);
|
||||||
let collapsed = sidebar.collapsed;
|
|
||||||
const [open, setOpen] = useState({ Dashboard: false, Account: false });
|
const [open, setOpen] = useState({ Dashboard: false, Account: false });
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
const [popup, setPopup] = useState();
|
const [popup, setPopup] = useState();
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ const uiSlice = createSlice({
|
|||||||
initialState,
|
initialState,
|
||||||
reducers: {
|
reducers: {
|
||||||
setRowsPerPage: (state, action) => {
|
setRowsPerPage: (state, action) => {
|
||||||
state[action.payload.table].rowsPerPage = action.payload.value;
|
const { table, value } = action.payload;
|
||||||
|
if (state[table]) {
|
||||||
|
state[table].rowsPerPage = value;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
toggleSidebar: (state) => {
|
toggleSidebar: (state) => {
|
||||||
state.sidebar.collapsed = !state.sidebar.collapsed;
|
state.sidebar.collapsed = !state.sidebar.collapsed;
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ const SkeletonLayout = () => {
|
|||||||
* @component
|
* @component
|
||||||
*/
|
*/
|
||||||
const DetailsPage = ({ isAdmin }) => {
|
const DetailsPage = ({ isAdmin }) => {
|
||||||
|
const theme = useTheme();
|
||||||
const [monitor, setMonitor] = useState({});
|
const [monitor, setMonitor] = useState({});
|
||||||
const { monitorId } = useParams();
|
const { monitorId } = useParams();
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
@@ -184,7 +185,6 @@ const DetailsPage = ({ isAdmin }) => {
|
|||||||
fetchCertificate();
|
fetchCertificate();
|
||||||
}, [authToken, monitorId]);
|
}, [authToken, monitorId]);
|
||||||
|
|
||||||
const theme = useTheme();
|
|
||||||
let loading = Object.keys(monitor).length === 0;
|
let loading = Object.keys(monitor).length === 0;
|
||||||
return (
|
return (
|
||||||
<Box className="monitor-details">
|
<Box className="monitor-details">
|
||||||
|
|||||||
Reference in new issue
Block a user