Skip to content

Commit 58caf6a

Browse files
committed
fix: Improve minimal performance of code
1 parent 05ab1e9 commit 58caf6a

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Diff for: src/components/UncontrolledTabs.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,12 @@ const UncontrolledTabs = (props) => {
207207
determineCanUseActiveElement(environment);
208208
}
209209

210-
if (canUseActiveElement) {
210+
const env =
211+
environment || (typeof window !== 'undefined' ? window : undefined);
212+
if (canUseActiveElement && env) {
211213
wasTabFocused = React.Children.toArray(child.props.children)
212214
.filter(isTab)
213-
.some((tab, i) => {
214-
const env =
215-
environment ||
216-
(typeof window !== 'undefined' ? window : undefined);
217-
return env && env.document.activeElement === getTab(i);
218-
});
215+
.some((tab, i) => env.document.activeElement === getTab(i));
219216
}
220217

221218
result = cloneElement(child, {

0 commit comments

Comments
 (0)