{"record":{"id":"bde310f659d14ec8","repo":"TanStack/table","slug":"useheadercontext-must-be-used-within-an-apphead-bde310","errorCode":null,"errorMessage":"`useHeaderContext` must be used within an `AppHeader` or `AppFooter` component.","messagePattern":"`useHeaderContext` must be used within an `AppHeader` or `AppFooter` component\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/solid-table/src/createTableHook.tsx","lineNumber":761,"sourceCode":"   *     <input\n   *       value={(header.column.getFilterValue() ?? '') as string}\n   *       onChange={(e) => header.column.setFilterValue(e.target.value)}\n   *       placeholder=\"Filter...\"\n   *     />\n   *   )\n   * }\n   * ```\n   */\n  function useHeaderContext<TValue extends CellData = CellData>(): Header<\n    TFeatures,\n    any,\n    TValue\n  > &\n    THeaderComponents & { FlexRender: () => JSXElement } {\n    const header = useContext(HeaderContext)\n\n    if (!header) {\n      throw new Error(\n        '`useHeaderContext` must be used within an `AppHeader` or `AppFooter` component.',\n      )\n    }\n\n    // `<table.AppHeader>` / `<table.AppFooter>` Object.assign `headerComponents`\n    // and `FlexRender` onto the same header instance they provide.\n    return header as unknown as Header<TFeatures, any, TValue> &\n      THeaderComponents & { FlexRender: () => JSXElement }\n  }\n\n  /**\n   * Context-aware FlexRender component for cells.\n   * Uses the cell from context, so no need to pass cell prop.\n   */\n  function CellFlexRender() {\n    const cell = useCellContext()\n    return <FlexRender cell={cell} />\n  }","sourceCodeStart":743,"sourceCodeEnd":779,"githubUrl":"https://github.com/TanStack/table/blob/d01c01bedbab0ff6c2641f18b2fc9a11545d9bf6/packages/solid-table/src/createTableHook.tsx#L743-L779","documentation":"`useHeaderContext` in the Solid adapter reads the header context provided by `<table.AppHeader>` or `<table.AppFooter>`. When called with no such provider above it, the context is undefined and this error is thrown. AppHeader/AppFooter also Object.assign `headerComponents` and `FlexRender` onto the header instance, which are unavailable outside them.","triggerScenarios":"Calling `useHeaderContext()` outside `<table.AppHeader header={header}>`/`<table.AppFooter header={header}>`; portal-rendered consumers; duplicate solid-table installs producing separate context objects.","commonSituations":"Custom sort/resize controls placed outside the header wrapper after refactor; isolated storybook/test mounts; mixed package versions across a workspace.","solutions":["Wrap the component with `<table.AppHeader header={header}>` (or AppFooter).","Move the component into the provider's children in the same reactive root.","Dedupe solid-table versions so the context module identity matches.","Read `useContext(HeaderContext)` directly and null-check if header access is optional."],"exampleFix":"// before\nfunction SortToggle() {\n  const header = useHeaderContext()\n  return <button onClick={() => header.column.toggleSorting()}>Sort</button>\n}\n\n// after\n<table.AppHeader header={header}>\n  <SortToggle />\n</table.AppHeader>","handlingStrategy":"validation","validationCode":"import { useContext } from 'solid-js'\nimport { HeaderContext } from '@your-scope/solid-table'\n\nfunction useSafeHeader() {\n  const header = useContext(HeaderContext)\n  if (!header) {\n    console.error('useHeaderContext requires <table.AppHeader> or <table.AppFooter> above this component')\n  }\n  return header\n}","typeGuard":"function hasHeader<T>(h: T | null | undefined): h is T {\n  return h != null\n}","tryCatchPattern":"try {\n  const header = useHeaderContext()\n  // use header\n} catch (err) {\n  if (err instanceof Error && err.message.includes('useHeaderContext')) {\n    return null\n  }\n  throw err\n}","preventionTips":["Render header consumers inside table.AppHeader/table.AppFooter only.","Pair provider and consumer in one wrapper component.","Dedupe solid-table package versions.","Use provider-inclusive test mount helpers."],"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"}