{"record":{"id":"a08f337d9e993f69","repo":"TanStack/table","slug":"usecellcontext-must-be-used-within-an-appcell-a08f33","errorCode":null,"errorMessage":"`useCellContext` must be used within an `AppCell` component. Make sure your component is wrapped with `<table.AppCell cell={cell}>...</table.AppCell>`.","messagePattern":"`useCellContext` must be used within an `AppCell` component\\. Make sure your component is wrapped with `<table\\.AppCell cell=(.+?)>\\.\\.\\.</table\\.AppCell>`\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/react-table/src/createTableHookContexts.tsx","lineNumber":132,"sourceCode":"    }\n\n    return table as unknown as ReactTable<TFeatures, TTableData>\n  }\n\n  /**\n   * Access the cell instance from within an `AppCell` wrapper bound to these\n   * scoped contexts.\n   */\n  function useCellContext<TValue extends CellData = CellData>(): Cell<\n    TFeatures,\n    any,\n    TValue\n  > {\n    // eslint-disable-next-line @eslint-react/no-use-context -- intentional for React 18\n    const cell = useContext(cellContext)\n\n    if (!cell) {\n      throw new Error(\n        '`useCellContext` must be used within an `AppCell` component. ' +\n          'Make sure your component is wrapped with `<table.AppCell cell={cell}>...</table.AppCell>`.',\n      )\n    }\n\n    return cell as unknown as Cell<TFeatures, any, TValue>\n  }\n\n  /**\n   * Access the header instance from within an `AppHeader` or `AppFooter` wrapper\n   * bound to these scoped contexts.\n   */\n  function useHeaderContext<TValue extends CellData = CellData>(): Header<\n    TFeatures,\n    any,\n    TValue\n  > {\n    // eslint-disable-next-line @eslint-react/no-use-context -- intentional for React 18","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/TanStack/table/blob/d01c01bedbab0ff6c2641f18b2fc9a11545d9bf6/packages/react-table/src/createTableHookContexts.tsx#L114-L150","documentation":"`useCellContext` in `createTableHookContexts.tsx` reads `cellContext` provided by `<table.AppCell cell={cell}>`. If the hook is called with no AppCell provider above it, the context is undefined and this error is thrown, blocking access to cell APIs without a cell instance.","triggerScenarios":"Calling `useCellContext()` in a component outside `<table.AppCell cell={cell}>`; portal or separate-root rendering; multiple installs of the package breaking context identity.","commonSituations":"Reusable cell widgets moved into a shared library without the provider; isolated component tests; refactors that hoisted the component out of AppCell.","solutions":["Wrap the component with `<table.AppCell cell={cell}>...</table.AppCell>`.","Move the component into AppCell's children in the cell renderer.","Dedupe table package versions so the context module is single.","Read `useContext(cellContext)` directly and null-check if the cell is optional."],"exampleFix":"// before\nfunction CellActions() {\n  const cell = useCellContext()\n  return <button onClick={() => cell.row.toggleSelected()}>Select</button>\n}\n\n// after\n<table.AppCell cell={cell}>\n  <CellActions />\n</table.AppCell>","handlingStrategy":"validation","validationCode":"import { useContext } from 'react'\nimport { cellContext } from '@your-scope/react-table/contexts'\n\nfunction useSafeCell() {\n  const cell = useContext(cellContext)\n  if (!cell) {\n    console.error('useCellContext requires <table.AppCell cell={cell}> above this component')\n  }\n  return cell\n}","typeGuard":"function hasCell<T>(c: T | null | undefined): c is T {\n  return c != null\n}","tryCatchPattern":"try {\n  const cell = useCellContext()\n  // use cell\n} catch (err) {\n  if (err instanceof Error && err.message.includes('useCellContext')) {\n    return null\n  }\n  throw err\n}","preventionTips":["Wrap cell consumers with table.AppCell at the call site.","Keep provider and consumer in the same component boundary.","Verify single package install.","Use provider-inclusive test wrappers."],"tags":["react","react-context","missing-provider"],"backgroundTag":"missing-context-provider","analyzedSha":"d01c01bedbab0ff6c2641f18b2fc9a11545d9bf6","analyzedAt":"2026-08-28T21:52:44.679Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}