}).reduce((prev, next) => {
return { ...next, ...prev };
}, {});
-
- setPathData({ ...pathData, ...newState });
+ setPathData((state) => ({ ...state, ...newState }));
})
.finally(() => {
setIsLoading(false);
if (breadcrumbPath) {
const index = path.indexOf(breadcrumbPath);
- setPath([...path.slice(0, index + 1)]);
+ setPath((state) => ([...state.slice(0, index + 1)]));
}
if (parentPath && type === 'directory') {
path.pop()
}
- setPath([...path, parentPath]);
+ setPath((state) => ([...state, parentPath]));
}
if (subfolderPath && type === 'directory') {
- setPath([...path, subfolderPath]);
+ setPath((state) => ([...state, subfolderPath]));
}
if (elem.dataset.id && type === 'file') {
<div className={classes.wrapper}>
<div className={classNames(classes.leftPanel, path.length > 1 ? classes.leftPanelVisible : classes.leftPanelHidden)} data-cy="collection-files-left-panel">
<Tooltip title="Go back" className={path.length > 1 ? classes.backButton : classes.backButtonHidden}>
- <IconButton onClick={() => setPath([...path.slice(0, path.length -1)])}>
+ <IconButton onClick={() => setPath((state) => ([...state.slice(0, state.length -1)]))}>
<BackIcon />
</IconButton>
</Tooltip>