From b29c0fe8cbab43e99edb863d7985228ef25e6f80 Mon Sep 17 00:00:00 2001 From: jacobherrington Date: Sat, 29 Sep 2018 23:17:19 -0500 Subject: [PATCH] Fix TypeError thrown on the Snippets page This commit protects from a TypeError that is consistently thrown on the Snippets page. --- browser/main/modals/PreferencesModal/SnippetTab.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/browser/main/modals/PreferencesModal/SnippetTab.js b/browser/main/modals/PreferencesModal/SnippetTab.js index e35ecd69..0e154c29 100644 --- a/browser/main/modals/PreferencesModal/SnippetTab.js +++ b/browser/main/modals/PreferencesModal/SnippetTab.js @@ -27,12 +27,14 @@ class SnippetTab extends React.Component { handleSnippetSelect (snippet) { const { currentSnippet } = this.state - if (currentSnippet === null || currentSnippet.id !== snippet.id) { - dataApi.fetchSnippet(snippet.id).then(changedSnippet => { - // notify the snippet editor to load the content of the new snippet - this.snippetEditor.onSnippetChanged(changedSnippet) - this.setState({currentSnippet: changedSnippet}) - }) + if (snippet !== null) { + if (currentSnippet === null || currentSnippet.id !== snippet.id) { + dataApi.fetchSnippet(snippet.id).then(changedSnippet => { + // notify the snippet editor to load the content of the new snippet + this.snippetEditor.onSnippetChanged(changedSnippet) + this.setState({currentSnippet: changedSnippet}) + }) + } } }