
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
react-virtualized-image-measurer
Advanced tools
$ npm install react-virtualized-image-measurer --save-dev
https://codesandbox.io/s/7y66p25qv6
Component accepts an array of items, tries to extract an image from each item using image
callback prop,
then loads the image, measures it and provides the outcome to children
render-prop.
const list = [
{
image: 'http://...',
title: 'Foo'
}
//...more
];
export default () => (
<ImageMeasurer
items={list}
image={item => item.image}
defaultHeight={100}
defaultWidth={100}
>
{({itemsWithSizes, sizes}) => (
// itemsWithSizes = [{item: listItem, size: {width: x, height: x}]
// sizes = {'src': {width: x, height: x}}
<MasonryComponent itemsWithSizes={itemsWithSizes}/>
)}
</ImageMeasurer>
);
You can return custom width and height from onError
callback prop. If nothing was returned defaultWidth
and
defaultHeight
will be used.
export default () => (
<ImageMeasurer
onError={(event, item, src) => {
console.error('Cannot load image', src, 'for item', item, 'event', event);
return {width: 100, height: 100};
}}
>...</ImageMeasurer>
);
You should not do anything extra if you simply add items to the end of original array. But if you filter items, change
their order or insert items in the middle (basically anything that affect old items positioning), you have to manually
reset Masonry
caches due to it's optimizations.
To do that you will have to save Masonry
's ref
somewhere:
const setRef = (node) => masonryRef = node;
<Masonry ref={setRef}/>
And using this ref
call following methods:
cellMeasurerCache.clearAll();
cellPositioner.reset(cellPositionerConfig);
masonryRef.clearCellPositions();
You can supply a custom key extractor callback prop in case you have duplicates in your array:
export default () => (
<ImageMeasurer
keyMapper={(item, index) => item.id}
>...</ImageMeasurer>
);
FAQs
Image Preloader for React & React Virtualized
The npm package react-virtualized-image-measurer receives a total of 362 weekly downloads. As such, react-virtualized-image-measurer popularity was classified as not popular.
We found that react-virtualized-image-measurer 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.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.