react-tiny-virtual-list icon indicating copy to clipboard operation
react-tiny-virtual-list copied to clipboard

enum ALIGNMENT needs exported to pass values to scrollToAlignment prop with TypeScript

Open mts opened this issue 7 years ago • 6 comments

Hello  🙂

I am using react-tiny-virtual-list in a real-world TypeScript project.

Apparently the type of scrollToAlignment prop has changed from string in v2.1.4 to enum ALIGNMENT in v2.2.0 and scrollToAlignment props which is not available at the moment in TypeScript because enum ALIGNMENT is not exported in index.d.ts

I could only use scrollToAlignment prop with a value of appropriate type namely enum ALIGNMENT as follows:

in some-project > node_modules/react-tiny-virtual-list/types/index.d.ts

export { DIRECTION as ScrollDirection, ALIGNMENT as scrollAlignment } from './constants';

in some-project > some-component

<VirtualList
    width="99%"
    height={100}
    itemCount={5}
    itemSize={30}
    scrollToIndex={0}
    renderItem={doSomething}
    scrollToAlignment={scrollAlignment.AUTO}
    onItemsRendered={doSomething}
/>

Appreciated if scrollToAlignment is available to use in TypeScript in v2.2.0.

I made the following PR to offer a solution to this issue: https://github.com/clauderic/react-tiny-virtual-list/pull/69

mts avatar Nov 21 '18 08:11 mts

+1 is there anyway this can be prioritize? the only way to currently make this to work with typescript is by declaring an enum that duplicates the existing ALIGNMENT constant. is there anyway this can be exposed?

stephenotalora avatar Apr 12 '19 21:04 stephenotalora

@clauderic are you the maintainer of this repo? there's already a PR for this https://github.com/clauderic/react-tiny-virtual-list/pull/69 is there any way this can be merged and released to npm?

stephenotalora avatar Apr 12 '19 21:04 stephenotalora

@mts any reason why https://github.com/clauderic/react-tiny-virtual-list/pull/69 was never merged?

stephenotalora avatar Apr 12 '19 21:04 stephenotalora

@stephenotalora No idea. As a workaround, you can fork the repo, apply the changes you need and change your project's dependency for the time being to your fork instead if you like.

mts avatar Apr 13 '19 10:04 mts

thanks @mts, that's what I ended up doing 🙏 too bad the repo seems to have been abandoned...

stephenotalora avatar Apr 14 '19 21:04 stephenotalora

FYI, here is my workaround:

 scrollToAlignment={'auto' as any}

jigsawye avatar Apr 16 '19 09:04 jigsawye