Skip to content

Commit be42f3e

Browse files
remo5000ning-y
authored andcommitted
Fix mutation of state in (#28)
According to review from #19.
1 parent 85ba402 commit be42f3e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/reducers/playground.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ export const reducer: Reducer<IPlaygroundState> = (state = defaultPlayground, ac
5858
consoleLogs: [action.payload]
5959
})
6060
} else {
61-
lastOutput.consoleLogs = lastOutput.consoleLogs.concat(action.payload)
62-
newOutput = state.output.slice(0, -1).concat(lastOutput)
61+
const updatedLastOutput = {
62+
type: lastOutput.type,
63+
consoleLogs: lastOutput.consoleLogs.concat(action.payload)
64+
}
65+
newOutput = state.output.slice(0, -1).concat(updatedLastOutput)
6366
}
6467
return {
6568
...state,

0 commit comments

Comments
 (0)