Skip to content

Add commandsHistory to localstorage as a persistent store #522

@777aca

Description

@777aca

Hello,Bony Roopchandani

I now come across a feature that stores the history command to localStorage in the browser for persistent storage, so I use the appendCommandToHistory method, but when I try to do an array loop call for example:

["1", "2", "3"].forEach((item) => { appendCommandToHistory(item); });
When you use the keys on the keyboard to scroll through the history command, only the last command, that is, "3"
And I will see the code, the SRC/contexts/TerminalContext TSX appendCommandToHistory instead of the following is ok
` const appendCommandToHistory = (command: string) => {
if (!command) {
return;
}

setCommandsHistory((prevCommandsHistory) => [
  ...prevCommandsHistory,
  command,
]);

};`

I hope to update the code, and I am very interested in react-terminal and would like to be a contributor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions