imballinst / react-bs-datatable

Bootstrap datatable without jQuery. Features include: filter, sort, pagination, checkbox, and control customization.
https://imballinst.github.io/react-bs-datatable
MIT License
59 stars 20 forks source link

[Storybook - Async Examples] Cannot read source code or how to use #147

Closed twlai closed 1 year ago

twlai commented 2 years ago

Hello,

I want to see how the data table can be used in an Async environment.

However, the source code of the Async examples cannot be displayed. The following is an example:

https://imballinst.github.io/react-bs-datatable/?path=/story/controlled--async-pokemon

Can you help me?

Thank you!

imballinst commented 2 years ago

Hello @twlai, apologies for the late reply!

Here is the source for the Async Pokemon one:

https://github.com/imballinst/react-bs-datatable/blob/59e1fbe617b0a184b6149fa868289bedf8084a84/src/__stories__/01-Controlled.stories.tsx#L43-L70

The AsyncTable is also implemented in the same file, which fires the fetchFn every time the page changes (unfortunately I think the API doesn't support text filter and sort):

https://github.com/imballinst/react-bs-datatable/blob/59e1fbe617b0a184b6149fa868289bedf8084a84/src/__stories__/01-Controlled.stories.tsx#L213-L324

The fetchFn function is implemented at the end of the file:

https://github.com/imballinst/react-bs-datatable/blob/59e1fbe617b0a184b6149fa868289bedf8084a84/src/__stories__/01-Controlled.stories.tsx#L326-L343