0

Are there any packages/libraries/etc where I can import only the parts of react-virtualized that I need? Kind of like https://www.npmjs.com/package/lodash.debounce for lodash?

Mark Lodato
  • 386
  • 3
  • 14

1 Answers1

5

There are no separately-published modules like with Lodash. That's something I have considered doing at some point if I move to something like Yarn workspaces, but my time for maintaining this project is very limited and it's not a high enough priority for me.

For now, the "Getting Started" docs recommend the following technique:

// But if you only use a few react-virtualized components,
// And you're concerned about increasing your application's bundle size,
// You can directly import only the components you need, like so:
import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer'
import List from 'react-virtualized/dist/commonjs/List'

If the above syntax looks too cumbersome or you import RV in a lot of places, you could also configure a Webpack alias. For example, something like:

// webpack.config.js
alias: {
  'react-virtualized/list': 'react-virtualized/dist/es/List',
},

Then you can just import like so:

import List from 'react-virtualized/list';

<List {...props} />
bvaughn
  • 13,300
  • 45
  • 46