Wrapper component for react-infinite which auto calculates element heights.
npm install react-infinite-any-heightreact-infinite with automatic height calculation.
Try it - Live Example
npm install react-infinite-any-height (peer dependencies: react)
Check out Live Example,
or run locally
``bash`
git clone git@github.com:Radivarig/react-infinite-any-height.git
npm install
npm run devlocalhost:8080
navigate to
`javascript
// ...
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import InfiniteAnyHeight from 'react-infinite-any-height';
class App extends Component {
constructor() {
super();
const list = new Array(10000).fill('').map((x, i) => {
const height = 100 + Math.round(Math.abs((Math.sin(i) * 250)));
const style = { height, border: 'solid 1px', backgroundColor: #${height} };
return (
Height: { height + 2 }
Item: {i}
);
});
this.state = { list };
}
render() {
return (
preloadAdditionalHeight={window.innerHeight*2}
useWindowAsScrollContainer
/>
);
}
}
var elemDiv = document.createElement('div')
document.body.appendChild(elemDiv)
ReactDOM.render(
`
All props are passed to react-infinite as well.list
When updating make sure to use .slice(0) to change reference.useWindowAsScrollContainer
If is ommited, both containerHeight andscrollContainer` (the node that has the active .scrollTop) props are required.
MIT