From 8549451ee75fdfdabb1ba83f2139cbcd54ef2875 Mon Sep 17 00:00:00 2001 From: Deluan Date: Wed, 2 Sep 2020 12:41:21 -0400 Subject: [PATCH] Fix potential undefined property Not sure the reason, but I got this error: ``` Cannot read property 'id' of undefined at tn (SongTitleField.js:35) at Ka (react-dom.production.min.js:153) at vl (react-dom.production.min.js:261) at sc (react-dom.production.min.js:246) at lc (react-dom.production.min.js:246) ``` --- ui/src/common/SongContextMenu.js | 6 ++++-- ui/src/common/SongTitleField.js | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ui/src/common/SongContextMenu.js b/ui/src/common/SongContextMenu.js index bbf3de9cf..e3dfd63dd 100644 --- a/ui/src/common/SongContextMenu.js +++ b/ui/src/common/SongContextMenu.js @@ -100,8 +100,8 @@ const SongContextMenu = ({ } SongContextMenu.propTypes = { - resource: PropTypes.string, - record: PropTypes.object, + resource: PropTypes.string.isRequired, + record: PropTypes.object.isRequired, onAddToPlaylist: PropTypes.func, visible: PropTypes.bool, showStar: PropTypes.bool, @@ -109,6 +109,8 @@ SongContextMenu.propTypes = { SongContextMenu.defaultProps = { onAddToPlaylist: () => {}, + record: {}, + resource: 'song', visible: true, showStar: true, addLabel: true, diff --git a/ui/src/common/SongTitleField.js b/ui/src/common/SongTitleField.js index f7e94495f..60915deed 100644 --- a/ui/src/common/SongTitleField.js +++ b/ui/src/common/SongTitleField.js @@ -76,4 +76,9 @@ SongTitleField.propTypes = { showTrackNumbers: PropTypes.bool, } +SongTitleField.defaultProps = { + record: {}, + showTrackNumbers: false, +} + export default SongTitleField