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.7
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 wrapped component. 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, called when 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)

<MyNotifiedComponent ref="notifiedComponent" />

// to access your underling component use
// there is a bit of nesting because we need to allow the use as a hight order function
// or as a component
`this.refs.notifiedComponent.refs.notifyResizeWrapper.refs.component`

Component

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

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

// to access your underling component use
`this.refs.notifyResize.refs.component`

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 07 Mar 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.