Saltar al contenido
Skillpedia
Sitios e interfaces (frontend)29 mil · #9838

table-state

Qué hace

Esta habilidad explica cómo decidir si la tabla o tu propio código controla cada parte de su estado, como la paginación. Es para desarrolladores que necesitan que la tabla y su app coincidan en esos valores.

Cuándo usarla

  • ✓Cuando quieres definir el estado inicial de una tabla, como el tamaño de página, sin tomar control de él.
  • ✓Cuando necesitas controlar tú mismo una parte del estado y devolver sus cambios a la tabla.
  • ✓Cuando un cambio de estado de la tabla no se conserva o no se reinicia como esperas.

Link de la skill

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

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/TanStack/table/blob/main/packages/table-core/skills/table-state/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“¿Cómo configuro mi tabla para que empiece con un tamaño de página de 25 y que siga pudiendo cambiar de página por sí misma?”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

Muestra cómo definir valores iniciales para las partes que la tabla controla, cómo las partes controladas reciben un valor y un callback de cambio, y cómo reiniciar el estado con las funciones de la propia tabla.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

Shared table state

Read core first for stable model inputs and feature-gated types. State repair in an existing table can start here without adapter setup guidance.

Start with internal ownership

Omit state, atoms, and on<Slice>Change for slices that Table should own. Use initialState only to customize their initial values.

<!-- skill-snippet:check -->
import {
  constructTable,
  createColumnHelper,
  rowPaginationFeature,
  tableFeatures,
} from '@tanstack/table-core'
import { storeReactivityBindings } from '@tanstack/table-core/store-reactivity-bindings'

type Person = { id: string; name: string }
const features = tableFeatures({
  coreReactivityFeature: storeReactivityBindings(),
  rowPaginationFeature,
})
const helper = createColumnHelper<typeof features, Person>()
const columns = helper.columns([helper.accessor('name', {})])
const data: Person[] = [{ id: '1', name: 'Ada' }]
const table = constructTable({
  features,
  columns,
  data,
  initialState: { pagination: { pageIndex: 0, pageSize: 25 } },
})
table.setPageSize(50)
console.log(table.atoms.pagination.get().pageSize)
table.resetPagination()
console.log(table.atoms.pagination.get().pageSize)

This example demonstrates state only. A pagination row-model slot is needed when Table should also slice the data.

Choose one owner per slice

Owner Configuration Update path
Table Omit external values; optionally provide initialState.<slice> Feature setter or interaction handler
Framework state Current state.<slice> plus matching on<Slice>Change Callback applies the updater and the adapter receives the fresh value
External atom Stable writable atoms.<slice> Feature setters write directly to that atom; no matching callback is needed

Prefer the smallest set of externally owned slices. Load the adapter's table-state skill before selecting framework state or an external atom package. Native signals, runes, refs, tracked properties, and Store atoms have different adapter wiring.

An updater can be a value or a function of the previous value. In a custom callback, use functionalUpdate(updater, previousValue) from @tanstack/table-core and write the result to the owner. Supplying only on<Slice>Change replaces the internal updater without returning a current controlled value; supplying only state.<slice> leaves no effective external update path.

If both atoms.<slice> and state.<slice> are supplied, the external atom wins. Choose one owner deliberately; writing an internal base atom cannot change a slice resolved from an external atom.

Distinguish state reads and writes

  • table.baseAtoms contains internal writable atoms created from resolved initial state. Prefer feature setters; direct base-atom writes bypass feature-specific behavior.
  • table.atoms contains readonly resolved atoms per registered slice. table.atoms.pagination.get() reads whichever owner supplies pagination.
  • table.store is the readonly flat combination of resolved slices. table.store.state reads its current snapshot.
  • table.state, where an adapter exposes it, is adapter-selected state. Its presence and subscription behavior are not shared core contracts.

A feature must be registered before its state appears in initialState, state, atoms, baseAtoms, or store. Let the concrete feature registry infer TableState; import a slice type such as PaginationState for an external owner instead of widening the complete state.

A direct atom/store read is not a portable framework subscription. Its tracking depends on the adapter and the scope of the read. For reactive UI, load intent load <package>#table-state using the installed adapter package, for example intent load @tanstack/react-table#table-state. Use that skill's supported read and subscription APIs.

Initialization and resets

initialState resolves at construction. Changing the supplied object later does not reset the table. Keep the registered features and external atom identities stable for the instance lifetime.

Feature resets such as `r

Preguntas frecuentes

¿Siempre tengo que controlar el estado yo mismo?

No. La habilidad indica omitir el estado de cualquier parte que la tabla deba controlar, y usar initialState solo para valores de inicio.

¿Una parte del estado puede tener dos dueños?

No. La habilidad indica elegir un solo dueño por parte.

¿Esta habilidad cubre las lecturas reactivas de cada framework?

No. Cubre las reglas compartidas de propiedad y remite a la habilidad de estado del adaptador para las lecturas reactivas.

Detalles

Descripción original del autor

Choose Table v9 state ownership, atoms, initialization, updates, and resets. Load for controlled slices or state coordination; use the adapter state skill for reactive reads.

repo: TanStack/table

Popularidad

Estrellas en GitHub
29 mil
Posición en el ranking
#9838
Licencia
MIT
Actualizada
21/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas