{"record":{"id":"fa30951276619a2b","repo":"TanStack/table","slug":"usecellcontext-must-be-used-within-an-appcell-fa3095","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/octane-table/src/createTableHook.tsrx","lineNumber":225,"sourceCode":"\t}\n\n\t/**\n * Access the cell instance from within an `AppCell` wrapper. Use this in\n * custom `cellComponents` passed to `createTableHook`.\n *\n * @example\n * ```tsx\n * function TextCell() @{\n *   const cell = useCellContext<string>()\n *   <span>{cell.getValue()}</span>\n * }\n * ```\n */\n\tfunction useCellContext<TValue extends CellData = CellData>() {\n\t\tconst cell = useContext(CellContext);\n\n\t\tif (!cell) {\n\t\t\tthrow new Error('`useCellContext` must be used within an `AppCell` component. ' +\n\t\t\t\t'Make sure your component is wrapped with `<table.AppCell cell={cell}>...</table.AppCell>`.');\n\t\t}\n\n\t\t// `<table.AppCell>` Object.assign-es `cellComponents` and `FlexRender` onto\n\t\t// the same cell instance it provides, so this asserts the runtime shape.\n\t\treturn cell as unknown as\n\t\t\tCell<TFeatures, any, TValue> & TCellComponents & {\n\t\t\t\tFlexRender: () => OctaneNode;\n\t\t\t};\n\t}\n\n\t/**\n * Access the header instance from within an `AppHeader` or `AppFooter`\n * wrapper. Use this in custom `headerComponents` passed to `createTableHook`.\n *\n * @example\n * ```tsx\n * function SortIndicator() @{","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/TanStack/table/blob/d01c01bedbab0ff6c2641f18b2fc9a11545d9bf6/packages/octane-table/src/createTableHook.tsrx#L207-L243","documentation":"`useCellContext` in the Octane table reads `useContext(CellContext)`, provided only by `<table.AppCell cell={cell}>`. Outside that provider the context is null and the hook throws. It is a fail-fast assertion that the component is used as a cell child.","triggerScenarios":"Calling `useCellContext()` in a component rendered outside `<table.AppCell cell={cell}>` — e.g. directly under AppRow, inside AppHeader, or in a component reused in a non-cell location.","commonSituations":"Extracting cell content into a shared component and rendering it without the AppCell wrapper; confusing useCellContext with useTableContext; rendering cell components conditionally outside the cell slot.","solutions":["Wrap the component with `<table.AppCell cell={cell}>` so CellContext is provided.","Use `useHeaderContext`/`useTableContext` if the component actually lives in a header or table scope.","Pass the cell explicitly as a prop when the component must render outside a cell."],"exampleFix":"// before\n<CellBody /> // calls useCellContext()\n// after\n<table.AppCell cell={cell}>\n  <CellBody />\n</table.AppCell>","handlingStrategy":"validation","validationCode":"const cell = useContext(CellContext)\nif (!cell) {\n  console.warn('Component must be rendered inside <table.AppCell cell={cell}>')\n}","typeGuard":"function hasCellContext(c: unknown): c is NonNullable<typeof c> {\n  return c != null\n}","tryCatchPattern":"try {\n  const cell = useCellContext()\n} catch (e) {\n  if (e instanceof Error && e.message.includes('useCellContext')) {\n    // render fallback cell UI\n  } else throw e\n}","preventionTips":["Only mount cell components inside AppCell slots","Use the correct hook per scope (table/header/cell)","Avoid reusing cell components in non-table layouts without a cell prop","Add a comment documenting the AppCell requirement"],"tags":["react","octane-table","context","missing-provider"],"backgroundTag":"hook-used-outside-provider","analyzedSha":"d01c01bedbab0ff6c2641f18b2fc9a11545d9bf6","analyzedAt":"2026-08-28T21:52:44.679Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}