
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-useonview
Advanced tools
A react hook that returns a ref and does sth. when the element attached to that ref is scrolled into view.
A react hook that returns a ref and does sth. when the element attached to that ref is scrolled into view.
A react hook to trigger afunction when an component is scrolled into view. The given function will also be triggered on every subsequent scroll. So maybe add a closure to prevent this.
npm install --save react-useonview
or
yarn add react-useonview
import React, { Component } from 'react';
import useOnView from 'react-useonview';
const App = () => {
const [visible, setVisible] = useState(false);
const trigger = useOnView(() => setVisible(true));
return (
<div>
<div style={{ height: '100vh' }}></div>
<div
ref={trigger}
style={{ opacity: visible ? '1' : '0', transition: '1s' }}
>
I appear when scrolled into view
</div>
</div>
);
};
the function will probably execute several times
does not care whether the element which has the ref attached is actually visible
also executes when scrolled past element
| Parameter in order | Description |
|---|---|
| doSth | function that is executed when ref-element scrolled in or past view |
| fullView | should the object be in fullview to trigger doSth |
| name | values | default | description |
|---|---|---|---|
| fullView | boolean | false | should doSth be triggered at first contact or when the element is in full view? |
MIT © JustinHorn
FAQs
A react hook that returns a ref and does sth. when the element attached to that ref is scrolled into view.
The npm package react-useonview receives a total of 7 weekly downloads. As such, react-useonview popularity was classified as not popular.
We found that react-useonview 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.