Skip to content

Commit b29c0fe

Browse files
author
jacobherrington
committed
Fix TypeError thrown on the Snippets page
This commit protects from a TypeError that is consistently thrown on the Snippets page.
1 parent 03b8dbb commit b29c0fe

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

browser/main/modals/PreferencesModal/SnippetTab.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ class SnippetTab extends React.Component {
2727

2828
handleSnippetSelect (snippet) {
2929
const { currentSnippet } = this.state
30-
if (currentSnippet === null || currentSnippet.id !== snippet.id) {
31-
dataApi.fetchSnippet(snippet.id).then(changedSnippet => {
32-
// notify the snippet editor to load the content of the new snippet
33-
this.snippetEditor.onSnippetChanged(changedSnippet)
34-
this.setState({currentSnippet: changedSnippet})
35-
})
30+
if (snippet !== null) {
31+
if (currentSnippet === null || currentSnippet.id !== snippet.id) {
32+
dataApi.fetchSnippet(snippet.id).then(changedSnippet => {
33+
// notify the snippet editor to load the content of the new snippet
34+
this.snippetEditor.onSnippetChanged(changedSnippet)
35+
this.setState({currentSnippet: changedSnippet})
36+
})
37+
}
3638
}
3739
}
3840

0 commit comments

Comments
 (0)