mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-17 18:21:28 +10:00
replace JSON.parse(JSON.stringify({})) with structuredClone({})
This commit is contained in:
@ -34,7 +34,7 @@ export const moveItemInLayout = (
|
||||
): string[][][] => {
|
||||
try {
|
||||
// Create a deep copy of the layout to avoid mutating the original array
|
||||
const newLayout = JSON.parse(JSON.stringify(layout)) as string[][][];
|
||||
const newLayout = structuredClone(layout);
|
||||
|
||||
// Get the item from the current location
|
||||
const item = newLayout[current.page][current.column][current.section];
|
||||
|
||||
@ -84,7 +84,7 @@ describe("moveItemInLayout", () => {
|
||||
[["item1"], ["item2"]],
|
||||
[["item3"], ["item4"]],
|
||||
];
|
||||
const layoutCopy = JSON.parse(JSON.stringify(layout));
|
||||
const layoutCopy = structuredClone(layout);
|
||||
const current = { page: 0, column: 1, section: 0 };
|
||||
const target = { page: 1, column: 0, section: 1 };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user