Closed haoxiang-xu closed 1 month ago
due to <StackContainerWrapper mode={mode} command={command} data={data}>
requires refactoring
Problem happen because pop_command_by_id()
will always change cmd
when command
length is 0.
const pop_command_by_id = useCallback(
(id) => {
let popped_command = null;
if (!cmd[id] || cmd[id].length === 0) {
return popped_command;
}
setCmd((prevCommand) => {
const updatedCommand = { ...prevCommand };
if (updatedCommand[id] && updatedCommand[id].length > 0) {
popped_command = updatedCommand[id].splice(0, 1)[0];
if (updatedCommand[id].length === 0) {
delete updatedCommand[id];
}
}
return updatedCommand;
});
return popped_command;
},
[cmd]
);
if statement added to prevent unneccessary rerender
Still not fixing the problem, but the problem most likely happen in explorer
or tag
component
https://typeofnan.dev/fix-the-maximum-update-depth-exceeded-error-in-react/
After implement the
memo
wrapper forstack_frame