Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@rb/resize-observer
Advanced tools
ResizeObserver component for React.
Get notifications when an in the page changes its size.
The change in size can have any source - layout changes, DOM changes, browser resize - etc. The source is not important.
The ResizeObserver
API is a performant way of getting updates on size changes.
Warning! Only works if the global
ResizeObserver
is available. (As of January 2018 only Chrome >= 64 ships it natively.) You could use a polyfill to ensure it's available.
$ npm install @rb/resize-observer --save
# or
$ yarn add @rb/resize-observer
This component can be nested inside any parent component, and will notify when the node of the parent component changes its size.
import React from 'react';
import { render } from 'react-dom';
import ResizeObserver from '@rb/resize-observer';
const App = () => {
return (
<div style={{ width: '50vw', border: '1px solid red' }}>
This element has width: 50vw, so resize the browser window to get
notifications in the console
<ResizeObserver
onResize={({ width, height }) => {
console.log({ width, height });
}}
/>
</div>
);
};
render(<App />, document.getElementById('root'));
onResize: (contentRect)
- you can specify an onResize
function prop, which will be called with the contentRect
passed by the native ResizeObserver
API. You can destructure this to {width, height}
MIT
FAQs
ResizeObserver component for React
The npm package @rb/resize-observer receives a total of 3 weekly downloads. As such, @rb/resize-observer popularity was classified as not popular.
We found that @rb/resize-observer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.