Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
react-listen-resize
Advanced tools
Listener resize
yarn add react-listen-resize
npm install --save react-listen-resize
<script src="https://unpkg.com/react-listen-resize@0.1.0/dist/index.umd.js"></script>
OR
<script src="https://unpkg.com/react-listen-resize@0.1.0/dist/index.umd.min.js"></script>
Tips: You can find the library on window.ReactListenResize.
import { useListenResize, createListenResize, createWithListenResize } from 'react-listen-resize'
const {
useListenResize,
createListenResize,
createWithListenResize
} = require('react-listen-resize')
createListenResize is a normal function.
import { createListenResize } from 'react-listen-resize'
const [state, cancelListenResize] = createListenResize(
({ eventResize, state: { innerHeight, innerWidth } }) => {
console.log('eventResize-callback:: ', eventResize)
console.log('state-callback:: ', innerHeight, innerWidth)
},
true
)
createListenResize can pass two Params.
Property | Description | Type | Default | isRequired |
---|---|---|---|---|
callback | listen for resize trigger callback. | ({eventResize, state: {innerHeight, innerWidth}}) => void | undefined | false |
isInitExcutionCallback | Whether to excute the initial callback. | boolean | false | false |
createListenResize returns an array.
Property | Description | Type |
---|---|---|
array[0] - state | Return {innerHeight, innerWidth} | object |
array[1] - cancelListenResize | Call to cancel listening for resize | function |
useListenResize is a custom hook.
import { useListenResize } from 'react-listen-resize'
function Example() {
const [state, cancelListenResize] = useListenResize(
({ eventResize, state: { innerHeight, innerWidth } }) => {
console.log('eventResize-callback:: ', eventResize)
console.log('state-callback:: ', innerHeight, innerWidth)
},
true
)
}
useListenResize can pass two Params.
Property | Description | Type | Default | isRequired |
---|---|---|---|---|
callback | listen for resize trigger callback. | ({eventResize, state: {innerHeight, innerWidth}}) => void | undefined | false |
isInitExcutionCallback | Whether to excute the initial callback. | boolean | false | false |
useListenResize returns an array.
Property | Description | Type |
---|---|---|
array[0] - state | Return {innerHeight, innerWidth} . | object |
array[1] - cancelListenResize | Call to cancel listening for resize. | function |
createWithListenResize is a HOC.
import { createWithListenResize } from 'react-listen-resize'
function Example(props) {
const { innerHeight, innerWidth, cancelListenResize } = props
}
Example = createWithListenResize()(Example)
createWithListenResize return values in props.
Property | Description | Type |
---|---|---|
innerHeight | innerHeight | number |
innerWidth | innerWidth | number |
cancelListenResize | Call to cancel listening for resize. | function |
FAQs
Listening resize can use hooks、HOC、normal function.
The npm package react-listen-resize receives a total of 0 weekly downloads. As such, react-listen-resize popularity was classified as not popular.
We found that react-listen-resize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.