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.
@rescui/use-resize-observer
Advanced tools
ResizeObserver hook
This package is used for observing react elements.
It uses ResizeObserver
and alleviates some of its bugs.
It's best used together with React refs. It can be used with raw HTML
elements, although it's better to avoid that.
import React, { useRef } from 'react';
import { useResizeObserver } from '@rescui/use-resize-observer';
const MyComponent = () => {
const ref = useRef<HTMLElement>(null);
useResizeObserver(ref, (entry: ResizeObserverEntry) => {
// resize logic
});
return <div ref={ref}>To the moon!</div>;
};
Note: Avoid this option when possible due to additional re-renders when using callback refs and useState
. Use React ref instead.
import React, { useState } from 'react';
import { useResizeObserver } from '@rescui/use-resize-observer';
const MyComponent = () => {
const [el, setEl] = useState<HTMLElement>(null);
useResizeObserver(el, (entry: ResizeObserverEntry) => {
// resize logic
});
return <div ref={setEl}>To the moon!</div>;
};
Sometimes you need to observe only changes and ignore the first observer call.
In that case, you may use the ignoreFirstCall
option:
import React, { useState } from 'react';
import { useResizeObserver } from '@rescui/use-resize-observer';
const MyComponent = () => {
const ref = useRef<HTMLElement>(null);
useResizeObserver(
ref,
(entry: ResizeObserverEntry) => {
// resize logic
},
{ ignoreFirstCall: true }
);
return <div ref={ref}>To the moon!</div>;
};
FAQs
ResizeObserver hook
The npm package @rescui/use-resize-observer receives a total of 2,245 weekly downloads. As such, @rescui/use-resize-observer popularity was classified as popular.
We found that @rescui/use-resize-observer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.