
Company News
Socket Joins New OpenJS Program to Fund Node.js Security Work
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.
viewport-scroll
Advanced tools
A simple React component to track the window's viewport-scroll position.
npm install viewport-scroll
import ViewportScroll, { type ScrollHandlerType } from "viewport-scroll";
import { useState } from "react";
type State = {
isLoading: boolean,
data: {
id: number,
name: string,
}[],
};
const style = {
height: "97vh",
width: "80%",
overflowY: "auto",
margin: "auto",
};
export default function Component() {
const [user, setUser] = useState < State > { isLoading: false, data: [] };
const getCharacter: ScrollHandlerType = async ({ page, setHasMore }) => {
try {
setUser((prev) => ({ ...prev, isLoading: true }));
await new Promise((resolve) => setTimeout(resolve, 1000));
const data = await (await fetch(`https://rickandmortyapi.com/api/character?page=${page}`)).json();
const results = data?.results ?? [];
if (results.length === 0 || !data.info?.next) {
setHasMore(false);
}
setUser((prev) => ({ isLoading: false, data: [...prev.data, ...results] }));
} catch (error) {
setUser((prev) => ({ ...prev, isLoading: false }));
setHasMore(false);
}
};
return (
<ViewportScroll threshold={200} isLoading={user.isLoading} asyncHandler={getCharacter} style={style}>
{user.data.map((char) => (
<h3 key={char.id}>{char.name}</h3>
))}
{user.isLoading && <div>Loading more characters...</div>}
</ViewportScroll>
);
}
FAQs
A simple React component to track the window's viewport-scroll position.
The npm package viewport-scroll receives a total of 2 weekly downloads. As such, viewport-scroll popularity was classified as not popular.
We found that viewport-scroll 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.

Company News
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.

Security News
Two compromised GitHub Actions were re-enabled with malicious tags intact, exposing thousands of downstream repositories to Mini Shai-Hulud.

Research
/Security News
A malicious Firefox extension fetches its payload after installation to evade detection, steal Google session cookies, and automate account takeover.