import { Meta } from '@storybook/addon-docs/blocks'

<Meta title="pv-grid/Hooks/useGridRowMeta" />

# useGridRowMeta

If you need to use row meta data in a custom Renderer, you will need to use this hook to give your cell access to the row meta data.

```tsx
import { useGridRowMeta } from '@planview/pv-grid'
```

### Definition

```
function useGridRowMeta<T extends GridRowMeta = GridRowMeta>(
    rowId: GridRowId
) : TMetaModel
```

### Usage

Inside a cell renderer, you can use this hook to get access to meta data for a row. In addition to the few properties on `GridRowMeta`, you can add additional values and use them in your renderers.

```tsx
type Book = {
    id: string
    name: string
}

type BookMeta = GridRowMeta<Book>

const column: Column<Book> = {
    id: 'name',
    tree: true,
    cell: {
        Renderer({ rowId, label, tabIndex }) {
            const meta = useGridRowMeta<BookMeta>(rowId)

            return (
                <GridCellDefault
                    tabIndex={tabIndex}
                    label={label}
                    icon={meta.type === 'tree' ? <BookCollection /> : <Book />}
                />
            )
        },
    },
}
```
