본문으로 건너뛰기
Skillpedia
웹사이트 및 UI (프런트엔드)29k · #9826

table-state

하는 일

이 스킬은 현재 페이지 같은 테이블 설정을 React 상태에 보관하고 테이블이 이를 읽는 방법을 설명합니다. 화면이 테이블 상태와 일치해야 하는 React 개발자를 위한 것입니다.

사용하는 경우

  • ✓React 컴포넌트가 현재 페이지나 다른 테이블 설정을 보여줘야 할 때.
  • ✓컴포넌트에서 테이블로 테이블 설정 값을 전달해야 할 때.
  • ✓테이블 설정이 바뀌었는데 React 화면이 갱신되지 않을 때.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/TanStack/table/blob/main/packages/react-table/skills/table-state/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“다음 페이지 버튼을 누른 뒤 React 테이블의 페이지 번호를 어떻게 업데이트하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

React 상태 훅으로 설정을 저장하고, 맞는 업데이트 콜백과 함께 테이블에 전달하는 방법을 보여줍니다. 또 선택된 상태를 읽어 화면이 다시 그려지게 하는 방법도 설명합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

React table state

Before starting, run intent load @tanstack/table-core#table-state for shared ownership, initialization, updates, and resets. State repair does not require loading setup guidance.

Read reactive state

useTable selects all registered state by default. Its optional second-argument selector controls rerenders and the shape of table.state. table.atoms.<slice>.get() and table.store.state are current snapshots, not React subscriptions.

Use selected table.state in the owner render. For narrower boundaries, use table.Subscribe or useSelector from @tanstack/react-store. Without source, table.Subscribe selects from table.store; with source, it subscribes to that atom or store. Start with the default selector until render cost requires narrowing.

Control a slice

Keep features, columns, and data stable. Register the feature that owns the controlled slice. This example controls pagination without adding client row processing:

import { useState } from 'react'
import {
  rowPaginationFeature,
  tableFeatures,
  useTable,
  type PaginationState,
} from '@tanstack/react-table'

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

export function PageControl() {
  const [pagination, setPagination] = useState<PaginationState>({
    pageIndex: 0,
    pageSize: 20,
  })
  const table = useTable({
    features,
    columns,
    data,
    state: { pagination },
    onPaginationChange: setPagination,
  })
  return (
    <button onClick={() => table.setPageSize(50)}>
      {table.state.pagination.pageSize} rows per page
    </button>
  )
}

The React setter accepts both a value and a functional updater. Supply the current state.pagination together with onPaginationChange; a callback alone does not keep the table synchronized.

For an externally owned atom, create it with useCreateAtom from @tanstack/react-store, pass it in atoms.<slice>, and subscribe with useSelector where other UI needs its value.

Reactive boundaries

For React Compiler memoized children, put Subscribe inside the component hiding builder-method reads or pass the selected value as a changing prop. An outer subscription that ignores its value cannot refresh a stable child. In core-typed cell/header contexts, import standalone Subscribe.

For external-atom examples, selector dependencies, or fine-grained boundaries and React Compiler problems, read reactivity details. If this task changes processing features, run intent load @tanstack/table-core#table-features and read the relevant feature references.

API discovery

Inspect node_modules/@tanstack/react-table/dist/useTable.d.ts and Subscribe.d.ts, plus the installed @tanstack/react-store declarations for atom hooks.

자주 묻는 질문

이벤트 핸들러에서 읽은 값이 오래된 것처럼 보이는 이유는 무엇인가요?

핸들러 안에서 읽은 값은 그 순간의 스냅샷이므로, 화면은 선택된 상태나 구독을 통해서만 갱신됩니다.

값과 콜백이 둘 다 필요한가요?

네. 이 스킬은 변경 내용이 올바르게 반영되도록 제어되는 값마다 업데이트 콜백을 함께 전달하라고 설명합니다.

다시 그려지는 범위를 줄일 수 있나요?

네. 더 좁은 구독 방식도 있지만, 렌더링 비용 문제가 생기기 전까지는 기본 방식을 권장합니다.

상세 정보

작성자의 원본 설명

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

repo: TanStack/table

인기도

GitHub 스타
29k
순위
#9826
라이선스
MIT
업데이트
2026. 10. 21.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬