This commit is contained in:
Jan Prochazka
2020-12-26 16:07:23 +01:00
parent e8ffaaab6f
commit 96a52750e2
2 changed files with 16 additions and 10 deletions

View File

@@ -49,22 +49,26 @@ export default function Designer({ value, onChange }) {
const bringToFront = React.useCallback( const bringToFront = React.useCallback(
(table) => { (table) => {
onChange((current) => ({ const newValue = {
...current, ...value,
tables: [...(current.tables || []).filter((x) => x.designerId != table.designerId), table], tables: [...(value.tables || []).filter((x) => x.designerId != table.designerId), table],
})); };
onChange(newValue);
}, },
[onChange] [onChange, value]
); );
const removeTable = React.useCallback( const removeTable = React.useCallback(
(table) => { (table) => {
onChange((current) => ({ const newValue = {
...current, ...value,
tables: (current.tables || []).filter((x) => x.designerId != table.designerId), tables: (value.tables || []).filter((x) => x.designerId != table.designerId),
})); };
onChange(newValue);
}, },
[onChange] [onChange, value]
); );
return ( return (

View File

@@ -11,6 +11,8 @@ function getParsedLocalStorage(key) {
const res = JSON.parse(value); const res = JSON.parse(value);
return res; return res;
} catch (e) { } catch (e) {
// console.log('FAILED LOAD FROM STORAGE', e);
// console.log('VALUE', value);
localStorage.removeItem(key); localStorage.removeItem(key);
} }
} }