
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-img-toolkit
Advanced tools
A lightweight React library for optimizing image loading through preloading, lazy loading, and caching capabilities
A lightweight React library for optimizing image loading through preloading, lazy loading, and caching capabilities.
npm install react-img-toolkit
import { ImagePreloader } from 'react-img-toolkit';
function Gallery() {
const data = {
images: [
'https://example.com/image1.jpg',
'https://example.com/image2.jpg',
],
otherData: 'Hello World!',
};
return (
<ImagePreloader
data={data}
onSuccess={() => console.log('All images loaded!')}
onError={(error) => console.error('Failed to load:', error)}
>
{/* Your gallery content */}
</ImagePreloader>
);
}
Preload multiple images and track their loading status:
import { useImagePreloader } from 'react-img-toolkit';
function Gallery() {
const { imageUrls, count } = useImagePreloader([
'https://example.com/image1.jpg',
'https://example.com/image2.jpg'
]);
return (
<div>
<p>Loaded {count} images</p>
{imageUrls.map((url, index) => (
<img key={index} src={url} alt={`Image ${index + 1}`} />
))}
</div>
);
}
Load images only when they enter the viewport:
import { useLazyImage } from 'react-img-toolkit';
function LazyImage() {
const { ref, isIntersecting, isLoaded } = useLazyImage(
'https://example.com/large-image.jpg',
{
threshold: 0.1,
rootMargin: '50px'
}
);
return (
<div ref={ref}>
{isLoaded && (
<img src="https://example.com/large-image.jpg" alt="Lazy loaded" />
)}
</div>
);
}
Cache images for faster subsequent loads:
import { useImageCache } from 'react-img-toolkit';
function CachedImage() {
const { cachedSrc, loading, isCached } = useImageCache(
'https://example.com/image.jpg'
);
if (loading) return <div>Loading...</div>;
return <img src={cachedSrc} alt="Cached image" />;
}
Track the loading status of an image:
import { useImageStatus } from 'react-img-toolkit';
function ImageWithStatus() {
const status = useImageStatus('https://example.com/image.jpg');
return (
<div>
<p>Status: {status}</p>
{status === 'loaded' && (
<img src="https://example.com/image.jpg" alt="Status tracked" />
)}
</div>
);
}
| Prop | Type | Description |
|---|---|---|
| data | any | Any structured data. |
| onSuccess | () => void | Callback when all images are loaded |
| onError | (error: Error) => void | Callback when an error occurs |
| children | ReactNode | Content to render |
function useImagePreloader(
urls: string[],
options?: {
onSuccess?: () => void;
onError?: (error: Error) => void;
}
): {
imageUrls: string[];
count: number;
};
function useLazyImage(
src: string,
options?: {
threshold?: number;
rootMargin?: string;
}
): {
ref: RefObject<HTMLElement>;
isIntersecting: boolean;
isLoaded: boolean;
};
function useImageCache(
src: string
): {
cachedSrc: string | null;
loading: boolean;
isCached: boolean;
};
function useImageStatus(
src: string
): 'idle' | 'loading' | 'loaded' | 'error';
git clone https://github.com/IxtiyorDeveloper/react-img-toolkit.git
cd react-img-toolkit
npm install
npm run dev
npm test
Contributions are welcome! Please feel free to submit a Pull Request.
MIT
FAQs
A lightweight React library for optimizing image loading through preloading, lazy loading, and caching capabilities
The npm package react-img-toolkit receives a total of 13 weekly downloads. As such, react-img-toolkit popularity was classified as not popular.
We found that react-img-toolkit demonstrated a healthy version release cadence and project activity because the last version was released less than 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.