diff --git a/components/Editor.js b/components/Editor.js index ac711589f..357657d18 100644 --- a/components/Editor.js +++ b/components/Editor.js @@ -298,7 +298,7 @@ class Editor extends React.Component { this.context.snippet.update(this.props.snippet.id, this.state).then(() => this.props.setToasts({ type: 'SET', - toast: { children: 'Snippet saved', timeout: 3000 }, + toast: [{ children: 'Snippet saved', timeout: 3000 }], }) ) diff --git a/components/EditorContainer.js b/components/EditorContainer.js index b24226c35..3423886eb 100644 --- a/components/EditorContainer.js +++ b/components/EditorContainer.js @@ -25,6 +25,9 @@ function onReset() { function toastsReducer(curr, action) { switch (action.type) { + case 'ADD': { + return curr.concat(action.toast) + } case 'SET': { return action.toasts } @@ -49,6 +52,7 @@ function EditorContainer(props) { // XXX use context const [snippet, setSnippet] = React.useState(props.snippet || null) + // TODO update this reducer to only take one action const [toasts, setToasts] = React.useReducer(toastsReducer, []) const snippetId = snippet && snippet.id