I’m trying to add infinite loading to a React app. I’ve found this package: https://www.npmjs.com/package/react-visibility-sensor which seemed super-useful for this: the idea was to add it to the bottom of the list, and when it becomes visible, I can increase the limit.
But here’s what I get when I add it to packages.json (other npm packages - even react components - are ok)
error: couldn't read npm version lock information: Command failed: npm ERR! missing: react@^0.13.3, required by react-context@0.0.2
Are there any components/patterns to implement infinite scoll in meteor-react?
It works good. I added a helper which compares the length of the data with the current limit, if they’re equal and the sensor is visible, I increase the limit.
_loadMore(isVisible) {
if (isVisible) {
let currLimit = Session.get("itemsLimit");
Session.set("itemsLimit", currLimit + 10);
}
}
Basically when the number of items is equal to the current limit, the sensor is active. If the user scrolls down, the limit will be increased and the sensor becomes inactive. If the server sends down enough items, the sensor becomes active again.