# Troubleshooting

> Fix a blank or unstyled Birch UI Grid, rows that do not update, lost selection, ignored Pro options, CSP errors and slow large grids.

Start with the browser console. The grid reports problems there instead of throwing, with messages that start with `Birch UI Grid:`. Every message has a code and a fix on the [error codes](https://docs.birchui.com/support/errors.md) page, and `npx @birchui/doctor` checks a project for the most common setup problems.

| Symptom | Jump to |
| --- | --- |
| Nothing renders, or only a 120 pixel strip | [The grid is blank](#the-grid-is-blank) |
| Cells render as plain unstyled text | [The grid has no styles](#the-grid-has-no-styles) |
| `Refused to apply inline style` in the console | [A Content Security Policy blocks the styles](#a-content-security-policy-blocks-the-styles) |
| Pushed or edited rows do not appear | [Rows do not update after a change](#rows-do-not-update-after-a-change) |
| Selection or expanded rows reset after reloading data | [Selection is lost when data reloads](#selection-is-lost-when-data-reloads) |
| `getRowById()` returns the wrong row | [Two rows share an ID](#two-rows-share-an-id) |
| `Birch UI Grid: Row grouping needs RowGroupingModule…` | [A Grid Pro option is ignored](#a-grid-pro-option-is-ignored) |
| `Birch UI Grid: valueGetter for column … failed` | [A column callback fails](#a-column-callback-fails) |
| A watermark appears | [A watermark appears](#a-watermark-appears) |
| Types do not match, or modules do nothing | [Two copies of @birchui/core are installed](#two-copies-of-birchuicore-are-installed) |
| The bundle is larger than expected | [The bundle is too large](#the-bundle-is-too-large) |
| Scrolling or filtering is slow | [The grid is slow with large data](#the-grid-is-slow-with-large-data) |
| Problems that appear only in React, Vue, Svelte or Angular | [Framework adapters](#framework-adapters) |

## The grid is blank

**Cause.** The grid root fills its container with `width: 100%; height: 100%` and a minimum height of 120 pixels. It has no `height` option. A container without a height, such as an empty `div` in normal flow, collapses, so the grid shows a header and no rows, or nothing at all.

**Fix.** Give the container a height, or let a flex or grid layout size it:

```css
#orders {
  height: 520px;
}

.orders-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
}
.orders-panel > #orders {
  flex: 1;
  min-height: 0;
}
```

A grid created inside a hidden tab or a closed dialog measures zero size. It re-measures with `ResizeObserver` when the container becomes visible, so no extra call is needed. See [Sizing the grid](https://docs.birchui.com/grid/theming.md#sizing-the-grid).

## The grid has no styles

**Cause.** With `injectStyles: false`, the grid does not add its `<style id="lq-grid-styles">` element, and nothing styles it until you load the stylesheet yourself.

**Fix.** Import the CSS file from the package, plus `@birchui/grid-pro/styles.css` when you use Grid Pro modules:

```ts title="main.ts"
import '@birchui/core/styles.css';
import '@birchui/grid-pro/styles.css';
```

In a shadow root, append the exported strings instead: `gridStyles` from `@birchui/core` and `gridProStyles` from `@birchui/grid-pro`. See [How styles are loaded](https://docs.birchui.com/grid/theming.md#how-styles-are-loaded).

## A Content Security Policy blocks the styles

**Cause.** By default the grid injects a `<style>` element. A policy with `style-src 'self'` and no `'unsafe-inline'` blocks it, and the injected element has no nonce option.

**Fix.** Set `injectStyles: false` on every grid and load `@birchui/core/styles.css` as a stylesheet through your bundler, as in [The grid has no styles](#the-grid-has-no-styles). See also [Importing the CSS file](https://docs.birchui.com/getting-started/installation.md#importing-the-css-file).

## Rows do not update after a change

**Cause.** `update()` and `setRows()` apply a value only when its identity changes. Pushing into the array you already passed, or changing a property on a row object, is not detected.

**Fix.** Use the call that matches the change:

```ts
grid.applyTransaction({
  add: [{ id: 'SO-10431', customer: 'Fjord Outfitters', region: 'EMEA', total: 9100, status: 'Pending' }],
  update: [{ ...grid.getRowById('SO-10422')!, status: 'Shipped' }],
  remove: ['SO-10398'],
});

grid.setRows([...orders]);

order.total = 19250;
grid.refresh();
```

`applyTransaction` matches `update` rows by ID, so set `getRowId` for any grid that receives updates. See [Updating data](https://docs.birchui.com/grid/updating-data.md).

## Selection is lost when data reloads

**Cause.** Without `getRowId`, the grid assigns IDs such as `r1` per object instance. Re-fetched objects are new instances, so they get new IDs and lose selection, expansion and focus.

**Fix.** Return your primary key:

```ts
createGrid<Order>(container, { columns, rows: orders, getRowId: (order) => order.id });
```

See [Row IDs](https://docs.birchui.com/grid/rows.md#row-ids).

## Two rows share an ID

**Cause.** When `getRowId` returns the same value for two rows, the grid keeps both and suffixes the second ID with `#<index>`. `getRowById()` then finds only the first.

**Fix.** Return a value that is unique across the data set, for example combine fields: `` getRowId: (line) => `${line.orderId}:${line.lineNo}` ``.

## A Grid Pro option is ignored

**Cause.** Options such as `groupBy`, `rowGroup`, `aggFunc`, `treeData`, `pivot`, `rangeSelection`, `fillHandle`, `masterDetail` and `statusBar` belong to Grid Pro modules. Without the module, the grid ignores them and logs, once per feature:

```text
Birch UI Grid: Row grouping needs RowGroupingModule from @birchui/grid-pro. Add it with createGrid(el, { modules: [RowGroupingModule] }). The option is ignored until then.
```

**Fix.** Install `@birchui/grid-pro` and pass the named module in `modules`. See [Grid Pro troubleshooting](https://docs.birchui.com/grid-pro/troubleshooting.md) for module-specific issues.

## A column callback fails

**Cause.** The grid catches errors thrown by your callbacks so one bad row does not break rendering. It logs them with the column ID, for example `Birch UI Grid: valueGetter for column "margin" failed`, and the same pattern for `format`, `comparator`, `valueSetter` and `editable`.

**Fix.** Open the logged error for the stack trace. Most failures are missing fields on some rows; guard against `undefined` in the callback: `valueGetter: (row) => (row.cost ? row.revenue - row.cost : null)`.

## A watermark appears

**Cause.** `@birchui/core` is MIT and never checks a key. A watermark comes from a Grid Pro module that found no valid key on a non-local host.

**Fix.** Set the key with `setLicenseKey` from `@birchui/license` in your browser bundle, or pass `licenseKey` to the grid. The console warning names the reason. See [Grid Pro troubleshooting](https://docs.birchui.com/grid-pro/troubleshooting.md#a-watermark-appears) and [Licensing and activation](https://docs.birchui.com/getting-started/licensing.md#what-happens-without-a-valid-key).

## Two copies of @birchui/core are installed

**Cause.** When `@birchui/core`, `@birchui/grid-pro` and an adapter resolve to different versions, your app can load two copies of the core. TypeScript then reports that `GridModule` or `GridApi` types are not assignable, and module state can split between the copies.

**Fix.** Check the tree and align every `@birchui/*` package on one version:

```bash
npm ls @birchui/core
npm dedupe
```

If a dependency pins another version, force one with `overrides` in `package.json` (`resolutions` in Yarn, `pnpm.overrides` in pnpm):

```json title="package.json"
{
  "overrides": {
    "@birchui/core": "$@birchui/core"
  }
}
```

## The bundle is too large

**Cause.** Every package is ESM with `sideEffects` limited to its CSS files, so bundlers drop what you do not import. Size grows when you import everything, such as `AllProModules`, or import from a CommonJS wrapper that defeats tree shaking.

**Fix.** Import named exports only, list the Grid Pro modules you use instead of `AllProModules`, and keep features such as CSV export behind user actions where you can. Build with an ESM-aware bundler; there is no CommonJS build.

## The grid is slow with large data

**Cause.** The grid renders only visible rows and columns, but your code can still do work per row or per render. Common causes:

- a new `rows` array or new `columns` array on every render, so the grid re-indexes or re-resolves each time;
- a missing or unstable `getRowId`, such as one that returns `Math.random()` or the index;
- `setRows()` for live updates instead of `applyTransaction()`;
- a `valueGetter` or `format` that allocates, such as `new Intl.NumberFormat()` per call;
- heavy `cell` renderers, or listeners added per cell;
- `autoHeight` columns on very large data, which measure rendered rows in the DOM;
- a quick filter on a million rows without debouncing.

**Fix.** Keep options stable, set `getRowId` to a primary key, batch live updates through `applyTransaction()`, precompute derived fields and reuse formatters, and prefer a fixed `rowHeight`. [Guidance for a million rows](https://docs.birchui.com/grid/virtualization.md#guidance-for-a-million-rows) covers each of these with examples.

To see where the time goes, turn on debug logging. Pass `debug: true` in the grid options, or set `window.__BIRCHUI_DEBUG__ = true` before the grid is created. The grid then logs, with `console.info`, each pipeline stage with its duration and row count, each pipeline run, and each render with a running count:

```text
[Birch UI debug] stage "filter" 0.84 ms -> 18210 rows
[Birch UI debug] stage "sort" 12.40 ms -> 18210 rows
[Birch UI debug] pipeline #3 14.02 ms, 250000 source rows -> 18210 display rows
[Birch UI debug] render #41 (full) 3.10 ms
```

A slow stage points at its callbacks (`comparator`, `valueGetter`, filters). Many renders per keystroke point at options or rows recreated on every render. Debug logging is off by default and costs nothing when off; `debug: false` overrides the global flag.

## Framework adapters

Strict Mode double mounts, Vue proxies, Svelte `$state`, the Angular zone and server rendering are covered in [Framework troubleshooting](https://docs.birchui.com/frameworks/troubleshooting.md):

- [The widget is created twice in development](https://docs.birchui.com/frameworks/troubleshooting.md#the-widget-is-created-twice-in-development)
- [The widget updates on every render](https://docs.birchui.com/frameworks/troubleshooting.md#the-widget-updates-on-every-render)
- [Vue makes large data slow](https://docs.birchui.com/frameworks/troubleshooting.md#vue-makes-large-data-slow)
- [Svelte state makes large data slow](https://docs.birchui.com/frameworks/troubleshooting.md#svelte-state-makes-large-data-slow)
- [Angular views do not update after a widget event](https://docs.birchui.com/frameworks/troubleshooting.md#angular-views-do-not-update-after-a-widget-event)

## Related

- [API reference: @birchui/core](https://docs.birchui.com/api/core.md)
- [Updating data](https://docs.birchui.com/grid/updating-data.md)
- [Virtualization](https://docs.birchui.com/grid/virtualization.md)
