Socket
Socket
Sign inDemoInstall

rc-resize-observer

Package Overview
Dependencies
11
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rc-resize-observer

Resize observer for React


Version published
Weekly downloads
1.2M
decreased by-16.16%
Maintainers
2
Install size
713 kB
Created
Weekly downloads
 

Package description

What is rc-resize-observer?

The rc-resize-observer npm package is a React component that allows you to monitor and respond to changes in the size of a DOM element. It leverages the ResizeObserver API to provide a simple and efficient way to perform actions based on element or viewport resizing. This can be particularly useful in responsive design, where you might need to adjust layout or content based on the available space.

What are rc-resize-observer's main functionalities?

Observing size changes

This feature allows you to wrap any component or element with the ResizeObserver component. It will then call the provided `onResize` callback whenever the size of the wrapped element changes, passing an object containing the new size information.

import ResizeObserver from 'rc-resize-observer';

function MyComponent() {
  return (
    <ResizeObserver
      onResize={(sizeInfo) => {
        console.log('New size:', sizeInfo);
      }}
    >
      <div>Resize me!</div>
    </ResizeObserver>
  );
}

Other packages similar to rc-resize-observer

Readme

Source

rc-resize-observer

NPM version dumi build status Codecov npm download

Resize observer for React.

Live Demo

https://react-component.github.io/resize-observer/

Install

rc-resize-observer

Usage

import ResizeObserver from 'rc-resize-observer';
import { render } from 'react-dom';

render(
  <ResizeObserver
    onResize={() => {
      console.log('resized!');
    }}
  >
    <textarea />
  </ResizeObserver>,
  mountNode,
);

API

PropertyTypeDefaultDescription
disabledbooleanfalse
onResize({ width, height }) => void-Trigger when child node resized

Development

npm install
npm start

License

rc-resize-observer is released under the MIT license.

Keywords

FAQs

Last updated on 20 Oct 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc