From df9264d85df774ea0d46e26dcefa3d551846c056 Mon Sep 17 00:00:00 2001 From: romanhrynevych Date: Sat, 31 Aug 2024 09:55:53 +0300 Subject: [PATCH] docs(table): add `DataTableReactive` example and tanstack docs --- .../src/content/docs/components/data-table.md | 12 + .../default/example/DataTableReactiveDemo.vue | 273 ++++++++++++++++++ .../example/DataTableReactiveDemo.vue | 273 ++++++++++++++++++ 3 files changed, 558 insertions(+) create mode 100644 apps/www/src/lib/registry/default/example/DataTableReactiveDemo.vue create mode 100644 apps/www/src/lib/registry/new-york/example/DataTableReactiveDemo.vue diff --git a/apps/www/src/content/docs/components/data-table.md b/apps/www/src/content/docs/components/data-table.md index b43074b4..a07d3cc2 100644 --- a/apps/www/src/content/docs/components/data-table.md +++ b/apps/www/src/content/docs/components/data-table.md @@ -55,6 +55,18 @@ npm install @tanstack/vue-table +### Reactive Table + +Reactive table are added in `v8.20.0` of TanStack Table. You can see the [docs](https://tanstack.com/table/latest/docs/framework/vue/guide/table-state#using-reactive-data) for more information. We added an example where we are randomizing `status` column. One main point is that you need to mutate **full** data, as it is a `shallowRef` object. + +> __*⚠️ `shallowRef` is used under the hood for performance reasons, meaning that the data is not deeply reactive, only the `.value` is. To update the data you have to mutate the data directly.*__ + +Relative PR: [Tanstack/table #5687](https://github.com/TanStack/table/pull/5687#issuecomment-2281067245) + +If you want to mutate `props.data`, you should use `defineModule`. + + + ## Prerequisites We are going to build a table to show recent payments. Here's what our data looks like: diff --git a/apps/www/src/lib/registry/default/example/DataTableReactiveDemo.vue b/apps/www/src/lib/registry/default/example/DataTableReactiveDemo.vue new file mode 100644 index 00000000..25e48381 --- /dev/null +++ b/apps/www/src/lib/registry/default/example/DataTableReactiveDemo.vue @@ -0,0 +1,273 @@ + + + diff --git a/apps/www/src/lib/registry/new-york/example/DataTableReactiveDemo.vue b/apps/www/src/lib/registry/new-york/example/DataTableReactiveDemo.vue new file mode 100644 index 00000000..8dd21a81 --- /dev/null +++ b/apps/www/src/lib/registry/new-york/example/DataTableReactiveDemo.vue @@ -0,0 +1,273 @@ + + +