Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const activeBreakpoint = activeBreakpointForSize(width);
if (onChange && activeBreakpoint !== this.breakpoint) {
onChange(activeBreakpoint);
}
this.breakpoint = activeBreakpoint;
// Only update the state if an uncontrolled component exists.
if (tiny || small || medium || large || huge || enormous) {
let element;
if (width >= breakpoints.enormous && enormous) {
element = 'enormous';
} else if (width >= breakpoints.huge && huge) {
element = 'huge';
} else if (width >= breakpoints.large && large) {
element = 'large';
} else if (width >= breakpoints.medium && medium) {
element = 'medium';
} else if (width >= breakpoints.small && small) {
element = 'small';
} else {
element = 'tiny';
}
if (this.state.element !== element) {
this.setState({ element });
}
}
}