
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
react-detectable-overflow
Advanced tools
A React hook and component detecting overflow state.
npm install react-detectable-overflow
or
yarn add react-detectable-overflow
import * as React from 'react';
import { useOverflowDetector } from 'react-detectable-overflow';
const SampleComponent = () => {
const { ref, overflow } = useOverflowDetector({});
return (
<div
ref={ref}
style={{
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
overflow: 'hidden',
width: '120px',
backgroundColor: overflow ? 'red' : 'green',
}}
>
This is a sample text.
</div>
);
};
import * as React from 'react';
import DetectableOverflow from 'react-detectable-overflow';
const SampleComponent = () => {
const [overflow, setOverflow] = useState(false);
return (
<DetectableOverflow
onChange={setOverflow}
style={{
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
overflow: 'hidden',
width: '120px',
backgroundColor: overflow ? '#F9E9CF' : '#BCF2E7',
}}
>
This is a sample text.
</DetectableOverflow>
);
};
Be careful when the size of children
content depends on overflow state. The following code perhaps causes the infinite loop of changing overflow
state.
import * as React from 'react';
import { useOverflowDetector } from 'react-detectable-overflow';
// DO NOT WRITE LIKE THIS!
const SampleComponent = () => {
const { ref, overflow } = useOverflowDetector({});
return <div ref={ref}>{overflow ? 'short' : 'loooooooooooooooooooooooooooooooooooooong'}</div>;
};
This package is released under the MIT License, see LICENSE
handleHeight
and handleWidth
FAQs
React hook/component to detect overflow state
The npm package react-detectable-overflow receives a total of 8,452 weekly downloads. As such, react-detectable-overflow popularity was classified as popular.
We found that react-detectable-overflow demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.