-
-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Problem
In src/containers/Edit.tsx, the onEditorChange callback mutates the file object directly:
const onEditorChange = useCallback(
(newValue: string | undefined) => {
if (!newValue) return;
const file = simulation?.files.find(
(file) => file.fileName === selectedFile?.fileName,
);
if (file) {
file.content = newValue; // ← direct mutation
}
},
[selectedFile?.fileName, simulation?.files],
);This bypasses easy-peasy's immutability contract. While it may appear to work (because objects are references), it:
- Does not trigger React re-renders for components observing
simulation.files - Breaks time-travel debugging / state snapshots
- Is inconsistent with the rest of the codebase which uses proper actions
Solution
Add an updateFileContent action to the simulation store and dispatch it from onEditorChange instead of mutating the file object directly.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels