diff --git a/src/components/UncontrolledTabs.js b/src/components/UncontrolledTabs.js index 5a1d808b37..44ef38ccdd 100644 --- a/src/components/UncontrolledTabs.js +++ b/src/components/UncontrolledTabs.js @@ -207,15 +207,12 @@ const UncontrolledTabs = (props) => { determineCanUseActiveElement(environment); } - if (canUseActiveElement) { + const env = + environment || (typeof window !== 'undefined' ? window : undefined); + if (canUseActiveElement && env) { wasTabFocused = React.Children.toArray(child.props.children) .filter(isTab) - .some((tab, i) => { - const env = - environment || - (typeof window !== 'undefined' ? window : undefined); - return env && env.document.activeElement === getTab(i); - }); + .some((tab, i) => env.document.activeElement === getTab(i)); } result = cloneElement(child, {