Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tatchi/bs-react-virtual

BuckleScript bindings for react-virtual
https://github.com/tatchi/bs-react-virtual

bucklescript react-virtual reasonml

Last synced: about 2 months ago
JSON representation

BuckleScript bindings for react-virtual

Awesome Lists containing this project

README

        

# bs-react-virtual

[BuckleScript](https://github.com/bucklescript/bucklescript) bindings for [react-virtual](https://github.com/tannerlinsley/react-virtual)

![Build](https://github.com/tatchi/bs-react-virtual/workflows/Build/badge.svg)

## Installation

```sh
npm install --save @tatchi/bs-react-virtual
```

Then add `@tatchi/bs-react-virtual` to `bs-dependencies` in your `bsconfig.json`:

```js
{
...
"bs-dependencies": ["@tatchi/bs-react-virtual"]
}
```

## Example

```reason
[@react.component]
let make = () => {
let parentRef = React.useRef(Js.Nullable.null);

let rowVirtualizer =
ReactVirtual.useVirtual(
ReactVirtual.options(
~size=10000,
~parentRef,
~estimateSize=React.useCallback0(_ => 35),
~scrollToFn=(offset, defaultScrollToFn) => defaultScrollToFn(offset),
(),
),
);



rowVirtualizer.scrollToIndex(.
~index=0,
~options=Some({align: ReactVirtual.Align.auto}),
)
}>
{React.string("ScrollToIndex")}


rowVirtualizer.scrollToOffset(. ~offset=100, ~options=None)
}>
{React.string("ScrollToOffset")}



{rowVirtualizer.virtualItems
->Belt.Array.map(virtualRow =>

{React.string("Row " ++ string_of_int(virtualRow.index))}

)
->ReasonReact.array}


;
};
```