{"record":{"id":"7c31191c4f0ac678","repo":"TanStack/table","slug":"usetablecontext-must-be-used-within-an-apptable-7c3119","errorCode":null,"errorMessage":"`useTableContext` must be used within an `AppTable` component. Make sure your component is wrapped with `<table.AppTable>...</table.AppTable>`.","messagePattern":"`useTableContext` must be used within an `AppTable` component\\. Make sure your component is wrapped with `<table\\.AppTable>\\.\\.\\.</table\\.AppTable>`\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/solid-table/src/createTableHook.tsx","lineNumber":669,"sourceCode":"   *           <button onClick={() => table.nextPage()}>Next</button>\n   *         </div>\n   *       )}}\n   *     </table.Subscribe>\n   *   )\n   * }\n   * ```\n   */\n  function useTableContext<TData extends RowData = RowData>(): AppSolidTable<\n    TFeatures,\n    TData,\n    TTableComponents,\n    TCellComponents,\n    THeaderComponents\n  > {\n    const table = useContext(TableContext)\n\n    if (!table) {\n      throw new Error(\n        '`useTableContext` must be used within an `AppTable` component. ' +\n          'Make sure your component is wrapped with `<table.AppTable>...</table.AppTable>`.',\n      )\n    }\n\n    // The value provided by `<table.AppTable>` is the extended table (the App*\n    // wrapper components and `tableComponents` are Object.assign-ed onto the same\n    // instance `createAppTable` returns), so this asserts the runtime shape.\n    return table as unknown as AppSolidTable<\n      TFeatures,\n      TData,\n      TTableComponents,\n      TCellComponents,\n      THeaderComponents\n    >\n  }\n\n  /**","sourceCodeStart":651,"sourceCodeEnd":687,"githubUrl":"https://github.com/TanStack/table/blob/d01c01bedbab0ff6c2641f18b2fc9a11545d9bf6/packages/solid-table/src/createTableHook.tsx#L651-L687","documentation":"`useTableContext` in the Solid adapter reads the Solid context provided by `<table.AppTable>`. When no provider exists above the calling component, the context is undefined and this error is thrown. It prevents table APIs from being used without a table instance.","triggerScenarios":"Calling `useTableContext()` outside `<table.AppTable table={table}>`'s subtree; rendering consumers via Portal (solid-js/web) outside the provider; duplicated solid-table installs with separate context identities.","commonSituations":"Custom Solid toolbar/control components placed outside AppTable; test harnesses mounting only the child; refactors that extracted components from AppTable children.","solutions":["Wrap the consuming component with `<table.AppTable table={table}>...</table.AppTable>`.","Move the component into AppTable's children within the same reactive root.","Dedupe solid-table versions so the context module is shared.","Read the context directly (`useContext(TableContext)`) and handle undefined if usage is optional."],"exampleFix":"// before\nfunction RowCount() {\n  const table = useTableContext()\n  return <span>{table.getRowModel().rows.length}</span>\n}\n\n// after\n<table.AppTable table={table}>\n  <RowCount />\n</table.AppTable>","handlingStrategy":"validation","validationCode":"import { useContext } from 'solid-js'\nimport { TableContext } from '@your-scope/solid-table'\n\nfunction useSafeTable() {\n  const table = useContext(TableContext)\n  if (!table) {\n    console.error('useTableContext requires <table.AppTable> above this component')\n  }\n  return table\n}","typeGuard":"function hasTable<T>(t: T | null | undefined): t is T {\n  return t != null\n}","tryCatchPattern":"try {\n  const table = useTableContext()\n  // use table\n} catch (err) {\n  if (err instanceof Error && err.message.includes('useTableContext')) {\n    return null // not inside <table.AppTable>\n  }\n  throw err\n}","preventionTips":["Render Solid table consumers only inside <table.AppTable> children.","Avoid solid Portal usage that escapes the provider subtree.","Dedupe solid-table versions in the lockfile.","Use a test helper that wraps subjects in AppTable."],"tags":["solid","solid-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"}