From 12c18657d5807171723f9153436e5a42f135389a Mon Sep 17 00:00:00 2001 From: Leonard Kim Date: Tue, 18 Jun 2019 14:27:12 -0700 Subject: [PATCH] fix(welcome-page): make Tabs more resilient to bad props In case wrong props are passed in, such as pointing to an index that does not contain a value in the tabs array. --- react/features/welcome/components/Tabs.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/react/features/welcome/components/Tabs.js b/react/features/welcome/components/Tabs.js index 67e1b2cda..6ed8c31f5 100644 --- a/react/features/welcome/components/Tabs.js +++ b/react/features/welcome/components/Tabs.js @@ -29,6 +29,11 @@ type Props = { * */ export default class Tabs extends Component { + static defaultProps = { + tabs: [], + selected: 0 + }; + /** * Implements the React Components's render method. * @@ -36,7 +41,9 @@ export default class Tabs extends Component { */ render() { const { onSelect, selected, tabs } = this.props; - const { content } = tabs[selected]; + const { content = null } = tabs.length + ? tabs[Math.min(selected, tabs.length - 1)] + : {}; return (