MRT logoMaterial React Table

On This Page

    Installation

    material-react-table requires Material UI V5 packages as dependencies in your project.

    If you are already using Material UI, you probably already have most of these peer dependencies installed.

    Just double-check that you have the following in your package.json, or use the full install commands below.

    1. @mui/material (v5)

    2. @mui/x-date-pickers (v6) - (New in MRT v2)

    3. @mui/icons-material (v5)

    4. @emotion/react (v11)

    5. @emotion/styled (v11)

    6. react and react-dom (v18) - (MRT v2 will eventually use React 18 concurrent mode)

    Quick Install

    $ npm i material-react-table@beta

    Install With Required Peer Dependencies (Recommended)

    $ npm i material-react-table@beta @mui/material @mui/x-date-pickers @mui/icons-material @emotion/react @emotion/styled

    You do NOT need to install @tanstack/react-table, as it is already an internal dependency of material-react-table, and must use an exact version already specified internally.

    All internal dependencies: @tanstack/match-sorter-utils, @tanstack/react-table, @tanstack/react-virtual, and highlight-words

    Common Errors

    If you get an error like this:

    $ "Error: Element type is invalid: expected a string (for built-in components)
    or a class/function (for composite components) but got: undefined.

    You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

    Or You might be trying to import MaterialReactTable from the default export still, which is no longer supported in v2. Make sure you are importing the named export instead:

    - import MaterialReactTable from 'material-react-table'
    + import { MaterialReactTable } from 'material-react-table'

    Or you probably do not have the correct version of Material UI installed. Make sure all material ui packages are at least v5.11 or higher.

    If you are using an older version of webpack or create-react-app and get an error like this:

    $ ./node_modules/@tanstack/virtual-core/build/lib/index.esm.js 147:92
    Module parse failed: Unexpected token (147:92)
    File was processed with these loaders:

    Then try upgrading either webpack or react-scripts to the latest versions.

    FAQs

    React 17 or later is required by Material UI v5 itself. Some event listeners on Material UI TextField components will not work with React 16.x.

    No, you do not need to install TanStack Table in your project manually, as the latest TanStack Table version automatically gets installed under the hood by MRT itself as an internal dependency. You can imports and functions from '@tanstack/react-table' too.

    No, TypeScript is not required to use Material React Table, but it is a whole lot easier to use Material React Table with TypeScript, especially when defining columns. If you do use TypeScript, try to keep the latest TypeScript version installed, or at least TS version 4.8 or higher.