You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-notify-resize

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-notify-resize

React Component that notifies you whenever it is resized

0.1.4
npmnpm
Version published
Weekly downloads
4.8K
-32.58%
Maintainers
3
Weekly downloads
 
Created
Source

react-notify-resize

React Element that notifies you whenever it is resized - by any means.

It can be used as a function that takes a component and returns a NotifyResize. Or as a high order component that takes as prop factory a component.

You can be notified of resize by two means:

  • inside your component if you define a onResize method it will be called when resized
  • outside, NotifyResize takes a prop onResize calledwhen element resized

Usage

Example:

import notifyResize from 'react-notify-resize'

class MyComponent extends React.Component {
  
  render(){
    // the element you want to listen for resize must have position relative
    return <div style={{position: 'relative'}}>
      {
        // Include this helper inside the element you want to listen for resize
        // It renders two divs, with position absolute
        this.props.resizeTool
      }
    </div>
  }
      
  // will be called on resize if it is defined
  onResize(){
    // do something on resize
  }
}

const MyNotifiedComponent =  notifyResize(MyComponent)

<MyNotifiedComponent onResize={/* event called when elementchanges dimension */}

Function

import MyComponent from './MyComponent'
import notifyResize from 'react-notify-resize'

const MyNotifiedComponent = notifyResize(MyComponent)

Component

import MyComponent from './MyComponent'
import { NotifyResize } from 'react-notify-resize'

class SomeComponent extends React.Component {
  render(){
    return <NotifyResize factory={MyComponent} />
  }
}

Props

Returned Component from notifyResize

PropertyTypeDefaultDescription
onResizeFunction-called when component changes

NotifyResize Component

PropertyTypeDefaultDescription
factoryReact Component-component to decorate

Keywords

react

FAQs

Package last updated on 16 Feb 2016

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.