Skip to content

Commit

Permalink
Fix spurious data.py re-loads
Browse files Browse the repository at this point in the history
  • Loading branch information
WardBrian committed Jul 26, 2024
1 parent 01e9783 commit 805ca1b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gui/src/app/Scripting/DataGeneration/useDataGenState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ const useDataGenState = () => {

const { data, update } = useContext(ProjectContext);

// we don't want the callback to force itself to re-render when data is set
const lastData = useRef(data.dataFileContent);
const onData = useCallback(
(newData: unknown) => {
const dataJson = JSON.stringify(newData, null, 2);

if (dataJson !== data.dataFileContent) {
if (dataJson !== lastData.current) {
lastData.current = dataJson;
update({
type: "editFile",
content: dataJson,
Expand All @@ -35,7 +38,7 @@ const useDataGenState = () => {
);
}
},
[update, consoleRef, data.dataFileContent],
[update, consoleRef],
);

return { consoleRef, status, onStatus: setStatus, onData };
Expand Down

0 comments on commit 805ca1b

Please sign in to comment.