clauderic / react-tiny-virtual-list

A tiny but mighty 3kb list virtualization library, with zero dependencies 💪 Supports variable heights/widths, sticky items, scrolling to index, and more!
https://clauderic.github.io/react-tiny-virtual-list/
MIT License
2.46k stars 165 forks source link

not support commonjs require syntax #32

Closed ikzjfr0 closed 6 years ago

ikzjfr0 commented 6 years ago

I tried to include it with require syntax like: const VirtualList = require('react-tiny-virtual-list');

then use it in render method

render() {
    return (
      <div className="Root">
        <VirtualList
          width="auto"
          height={400}
          itemCount={1000}
          renderItem={this.renderItem}
          itemSize={50}
          className="VirtualList"
        />
      </div>
    );
  }

And got the following error from Chrome logs: warning.js:33 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.

clauderic commented 6 years ago

Try this:

const VirtualList = require('react-tiny-virtual-list').default;