Langsung ke konten
Skillpedia
Website & UI (frontend)29k · #9815

table-state

Fungsinya

Skill ini menjelaskan cara menyimpan pengaturan tabel, seperti halaman saat ini, dalam komponen Lit dan cara tabel bereaksi terhadapnya. Skill ini untuk pengembang Lit yang membutuhkan tampilan dan pengaturan tetap selaras.

Kapan dipakai

  • ✓Saat template Lit harus menampilkan halaman saat ini atau pengaturan tabel lainnya.
  • ✓Saat Anda perlu meneruskan pengaturan tabel dari komponen ke dalam tabel.
  • ✓Saat tampilan Lit tidak diperbarui setelah pengaturan tabel berubah.

Link skill

https://github.com/TanStack/table/blob/main/packages/lit-table/skills/table-state/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/TanStack/table/blob/main/packages/lit-table/skills/table-state/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit →

Contoh permintaan ke AI

“Bagaimana cara memperbarui nomor halaman di tampilan tabel Lit saya setelah tombol halaman berikutnya diklik?”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Skill menunjukkan cara menyimpan pengaturan sebagai properti reaktif Lit, meneruskannya ke tabel, dan mengembalikan pembaruan sehingga komponen dirender ulang.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

Load intent load @tanstack/table-core#table-state first for shared ownership, initialization, updater, and reset rules.

TableController selects all registered state by default and requests host updates when selected state changes. table.state is the selected render value. table.atoms.<slice>.get() and table.store.state are snapshots; those reads do not create a template subscription.

Controlled property setup

<!-- skill-snippet:check tsconfig=examples/lit/basic-table-controller/tsconfig.json -->
import { LitElement, html } from 'lit'
import { customElement, state } from 'lit/decorators.js'
import {
  TableController,
  rowPaginationFeature,
  tableFeatures,
  type PaginationState,
} from '@tanstack/lit-table'

const features = tableFeatures({ rowPaginationFeature })
const columns = [{ accessorKey: 'id' }]
const data = [{ id: '1' }]

@customElement('page-status')
export class PageStatus extends LitElement {
  @state() private pagination: PaginationState = { pageIndex: 0, pageSize: 10 }
  private controller = new TableController<typeof features, { id: string }>(
    this,
  )

  protected render() {
    const table = this.controller.table({
      features,
      columns,
      data,
      state: { pagination: this.pagination },
      onPaginationChange: (next) => {
        this.pagination =
          typeof next === 'function' ? next(this.pagination) : next
      },
    })
    return html`<button @click=${() => table.nextPage()}>
      Page ${table.state.pagination.pageIndex + 1}
    </button>`
  }
}

Reactive boundaries

  • Keep one controller on the host and pass current options during render. Keep features, columns, and data references stable across host updates.
  • A second controller.table(options, selector) argument changes the shape of table.state and gates host updates. Keep reused selectors stable.
  • Use table.subscribe(source, selector, renderCallback) for a template region that should update independently. Cache selector functions as host fields or module functions.
  • Feed every controlled callback result into the corresponding reactive property and pass it back through state. Use stable external atoms through atoms when sharing state outside the host.

Read for the task

For advanced reactive boundaries, shared atoms, or detailed subscription examples, read reactivity. For construction or rendering setup, read getting-started.

API discovery

Inspect node_modules/@tanstack/lit-table/dist/index.d.ts, then TableController.d.ts, flexRender.d.ts, or the relevant exported declaration. Core feature APIs are in node_modules/@tanstack/table-core/dist/features/.

Pertanyaan umum

Mengapa membaca nilai di handler berbeda dengan membacanya di template?

Pembacaan di template membuat tampilan tetap berlangganan perubahan, sedangkan nilai yang dibaca di handler adalah snapshot pada saat itu.

Apa yang dipilih controller secara default?

Controller memilih semua state tabel yang terdaftar secara default dan meminta pembaruan host saat state yang dipilih berubah.

Bisakah saya membatasi apa yang didengarkan template?

Bisa. Selector yang stabil dapat dipakai untuk satu bagian template, sebagaimana dijelaskan dalam panduan.

Detail

Deskripsi asli dari pembuat

Read and control Table v9 state in lit. Use for tracked reads, subscriptions, controlled slices, and framework-specific reactive boundaries.

repo: TanStack/table

Popularitas

Bintang GitHub
29k
Peringkat
#9815
Lisensi
MIT
Diperbarui
21/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa