MRT logoMantine React Table

On This Page

    Memoize Components Guide

    The memoMode prop will allow you to either memoize table cells, table rows, or the entire table body in order to improve render performance on large tables.
    However, memoizing these components will BREAK some features!
    DON'T MEMOIZE COMPONENTS UNLESS YOU KNOW WHAT YOU'RE DOING AND UNDERSTAND WHICH FEATURES WILL BREAK.

    Memoizing Table Cells

    Memoizing table cells can make a small but positive impact on render performance, and it is only incompatible with a few of the dynamic features of Mantine React Table.

    Cell Memoization Breaks the Following Features:

    density toggle, column resizing
    These features are incompatible with cell memoization because they depend on table cells being re-rendered.

    Features That Should Still Work with Cell Memoization:

    column hiding, column reordering, column pinning, editing, filtering, pagination, searching, sorting, row expanding, row selection, row virtualization,
    const table = useMantineReactTable({
    columns,
    data,
    enableDensityToggle: false, //density does not work with memoized cells
    memoMode: 'cells', // memoize table cells to improve render performance, but break some features
    })

    Memoized Cells

    AlbertaKautzer82321 Reichert BridgeArmandolandMississippi
    ImeldaHarber866 Kuvalis GrovesNorth KieranIowa
    LeonieHickle6094 Hudson ParkMandytownOregon
    CristalCarroll41222 Webster OvalSouth BlazeNew Mexico
    GoldaBrakus13718 Blick PortFort TressachesterNew Mexico
    JackelineLittle130 Kuhlman CreekGordonworthOhio
    KarsonFlatley9494 McCullough StravenuePricemouthDelaware
    JonathanBednar79954 Klein LoafAbdielvilleIndiana
    RockyFunk602 Josianne RampFort PearlworthMississippi
    AnthonyStokes71571 Santa MissionBeaumontAlaska
    BrendenGislason1291 Lyla GatewayLaceyNorth Carolina
    WebsterAnkunding229 Yasmin PassageDoylefurtArizona
    MarleyTowne5895 Bartoletti FallsKendale LakesIndiana
    AlexandrineHintz89462 Halvorson JunctionJerrodviewMissouri
    XavierLowe829 Rodriguez MallGrantbergTexas
    CamdenKemmer3110 Andreane VillagesCorpus ChristiNebraska
    AshtynHermiston6087 Howell PortsCastro ValleyTennessee
    KayleeBaumbach9576 Kristina StravenueSouth BeverlyColorado
    EugeneVonRueden43151 Rogelio AlleyBalistrerifurtTennessee
    RobinMcDermott5032 Batz ValleysShaynaburyMontana
    1-20 of 86
    1
    import { useMemo } from 'react';
    2
    import { MantineReactTable, type MRT_ColumnDef } from 'mantine-react-table';
    3
    import { Title } from '@mantine/core';
    4
    import { data, type Person } from './makeData';
    5
    6
    export const Example = () => {
    7
    const columns = useMemo<MRT_ColumnDef<Person>[]>(
    8
    () => [
    9
    {
    10
    accessorKey: 'firstName',
    11
    header: 'First Name',
    12
    },
    13
    {
    14
    accessorKey: 'lastName',
    15
    header: 'Last Name',
    16
    },
    17
    {
    18
    accessorKey: 'address',
    19
    header: 'Address',
    20
    },
    21
    {
    22
    accessorKey: 'city',
    23
    header: 'City',
    24
    },
    25
    {
    26
    accessorKey: 'state',
    27
    header: 'State',
    28
    },
    29
    ],
    30
    [],
    31
    );
    32
    33
    return (
    34
    <MantineReactTable
    35
    columns={columns}
    36
    data={data}
    37
    //just for demo purposes
    38
    defaultColumn={{
    39
    Cell: ({ cell }) => {
    40
    //see how often cells are re-rendered
    41
    // console.info('render cell', cell.id);
    42
    return <>{cell.getValue()}</>;
    43
    },
    44
    }}
    45
    editDisplayMode="row"
    46
    enableColumnOrdering
    47
    enableDensityToggle={false} //density toggle is not compatible with memoization
    48
    enableEditing
    49
    enablePinning
    50
    enableRowSelection
    51
    enableStickyHeader
    52
    initialState={{ pagination: { pageSize: 20, pageIndex: 0 } }}
    53
    memoMode="cells"
    54
    mantineTableContainerProps={{ sx: { maxHeight: '500px' } }}
    55
    renderDetailPanel={({ row }) => <div>{row.original.firstName}</div>}
    56
    renderTopToolbarCustomActions={() => (
    57
    <Title order={4}>Memoized Cells</Title>
    58
    )}
    59
    />
    60
    );
    61
    };
    62
    63
    export default Example;
    1
    import { useMemo } from 'react';
    2
    import { MantineReactTable } from 'mantine-react-table';
    3
    import { Title } from '@mantine/core';
    4
    import { data } from './makeData';
    5
    6
    export const Example = () => {
    7
    const columns = useMemo(
    8
    () => [
    9
    {
    10
    accessorKey: 'firstName',
    11
    header: 'First Name',
    12
    },
    13
    {
    14
    accessorKey: 'lastName',
    15
    header: 'Last Name',
    16
    },
    17
    {
    18
    accessorKey: 'address',
    19
    header: 'Address',
    20
    },
    21
    {
    22
    accessorKey: 'city',
    23
    header: 'City',
    24
    },
    25
    {
    26
    accessorKey: 'state',
    27
    header: 'State',
    28
    },
    29
    ],
    30
    [],
    31
    );
    32
    33
    return (
    34
    <MantineReactTable
    35
    columns={columns}
    36
    data={data}
    37
    //just for demo purposes
    38
    defaultColumn={{
    39
    Cell: ({ cell }) => {
    40
    //see how often cells are re-rendered
    41
    // console.info('render cell', cell.id);
    42
    return <>{cell.getValue()}</>;
    43
    },
    44
    }}
    45
    editDisplayMode="row"
    46
    enableColumnOrdering
    47
    enableDensityToggle={false} //density toggle is not compatible with memoization
    48
    enableEditing
    49
    enablePinning
    50
    enableRowSelection
    51
    enableStickyHeader
    52
    initialState={{ pagination: { pageSize: 20, pageIndex: 0 } }}
    53
    memoMode="cells"
    54
    mantineTableContainerProps={{ sx: { maxHeight: '500px' } }}
    55
    renderDetailPanel={({ row }) => <div>{row.original.firstName}</div>}
    56
    renderTopToolbarCustomActions={() => (
    57
    <Title order={4}>Memoized Cells</Title>
    58
    )}
    59
    />
    60
    );
    61
    };
    62
    63
    export default Example;

    Memoizing Table Rows

    Memoizing entire table rows can make an even more positive impact on render performance, but it is incompatible with a lot of the dynamic features of Mantine React Table.

    Row Memoization Breaks the Following Features:

    density toggle, column hiding, column resizing, column reordering, column pinning, row expanding, row selection
    These features are incompatible with row memoization because they require the entire row or cells to be re-rendered in order to update the UI.

    Features That Should Still Work with Row Memoization:

    filtering, pagination, searching, sorting, row virtualization,
    const table = useMantineReactTable({
    columns,
    data,
    enableDensityToggle: false, //density does not work with memoized rows
    enableHiding: false, //column hiding does not work with memoized rows
    memoMode: 'rows', // memoize table rows to improve render performance, but break a lot of features
    });

    Memoized Rows

    KyleighPadberg57128 Layla CanyonSedrickfurtAlabama
    MadelynnConroy006 Edna WellOak LawnUtah
    LisetteKing37090 Jordon LightFort NatalieOregon
    EmmetMedhurst27667 Tillman DrivePittsburgVermont
    MelissaStark70121 Gleichner ExpresswayEast CaryFlorida
    ThaddeusDavis250 Maybell SpringsEast NorvalmouthMissouri
    NettieFlatley96048 Abernathy WaySouth JackieMaine
    NarcisoVeum164 Prosacco EstateLake LinwoodsteadFlorida
    GiovaniWolff66888 Cullen CenterNew NicolashavenRhode Island
    JalenCormier50679 Darby DriveJamaalburghTexas
    JasminGibson72724 Crist GrovesWest HarleyIllinois
    MohammadHamill443 Wilhelm PlazaTerre HauteNew Mexico
    MiloDicki778 Wilfred MeadowKrislandArkansas
    ErichLynch60472 Price ParksLake MavisIllinois
    DeontaeBoyle4573 Zboncak UnderpassDandrefortMichigan
    AntwonTurcotte80006 Luettgen WellNew LucienneshireWest Virginia
    MarcellaHermann0339 Kunde JunctionsTallahasseeAlaska
    MaudAbernathy3590 Shayna PathNorth AftonSouth Carolina
    AsaCrist675 Tamara CornerNorth MelodyNew Mexico
    AnitaWiza47680 Rhianna RoadsWelchhavenOhio
    1-20 of 88
    1
    import { useMemo } from 'react';
    2
    import { MantineReactTable, type MRT_ColumnDef } from 'mantine-react-table';
    3
    import { Title } from '@mantine/core';
    4
    import { data, type Person } from './makeData';
    5
    6
    export const Example = () => {
    7
    const columns = useMemo<MRT_ColumnDef<Person>[]>(
    8
    () => [
    9
    {
    10
    accessorKey: 'firstName',
    11
    header: 'First Name',
    12
    },
    13
    {
    14
    accessorKey: 'lastName',
    15
    header: 'Last Name',
    16
    },
    17
    {
    18
    accessorKey: 'address',
    19
    header: 'Address',
    20
    },
    21
    {
    22
    accessorKey: 'city',
    23
    header: 'City',
    24
    },
    25
    {
    26
    accessorKey: 'state',
    27
    header: 'State',
    28
    },
    29
    ],
    30
    [],
    31
    );
    32
    33
    return (
    34
    <MantineReactTable
    35
    columns={columns}
    36
    data={data}
    37
    //just for demo purposes
    38
    defaultColumn={{
    39
    Cell: ({ cell }) => {
    40
    //see how often cells are re-rendered
    41
    // console.info('render cell', cell.id);
    42
    return <>{cell.getValue()}</>;
    43
    },
    44
    }}
    45
    enableDensityToggle={false} //density toggle is not compatible with memoization
    46
    enableHiding={false}
    47
    enableStickyHeader
    48
    initialState={{ pagination: { pageSize: 20, pageIndex: 0 } }}
    49
    memoMode="rows"
    50
    mantineTableContainerProps={{ sx: { maxHeight: '500px' } }}
    51
    renderTopToolbarCustomActions={() => (
    52
    <Title order={4}>Memoized Rows</Title>
    53
    )}
    54
    />
    55
    );
    56
    };
    57
    58
    export default Example;
    1
    import { useMemo } from 'react';
    2
    import { MantineReactTable } from 'mantine-react-table';
    3
    import { Title } from '@mantine/core';
    4
    import { data } from './makeData';
    5
    6
    export const Example = () => {
    7
    const columns = useMemo(
    8
    () => [
    9
    {
    10
    accessorKey: 'firstName',
    11
    header: 'First Name',
    12
    },
    13
    {
    14
    accessorKey: 'lastName',
    15
    header: 'Last Name',
    16
    },
    17
    {
    18
    accessorKey: 'address',
    19
    header: 'Address',
    20
    },
    21
    {
    22
    accessorKey: 'city',
    23
    header: 'City',
    24
    },
    25
    {
    26
    accessorKey: 'state',
    27
    header: 'State',
    28
    },
    29
    ],
    30
    [],
    31
    );
    32
    33
    return (
    34
    <MantineReactTable
    35
    columns={columns}
    36
    data={data}
    37
    //just for demo purposes
    38
    defaultColumn={{
    39
    Cell: ({ cell }) => {
    40
    //see how often cells are re-rendered
    41
    // console.info('render cell', cell.id);
    42
    return <>{cell.getValue()}</>;
    43
    },
    44
    }}
    45
    enableDensityToggle={false} //density toggle is not compatible with memoization
    46
    enableHiding={false}
    47
    enableStickyHeader
    48
    initialState={{ pagination: { pageSize: 20, pageIndex: 0 } }}
    49
    memoMode="rows"
    50
    mantineTableContainerProps={{ sx: { maxHeight: '500px' } }}
    51
    renderTopToolbarCustomActions={() => (
    52
    <Title order={4}>Memoized Rows</Title>
    53
    )}
    54
    />
    55
    );
    56
    };
    57
    58
    export default Example;

    Memoizing Table Body

    If your table never needs to re-render and you do not use any of the dynamic features of Mantine React Table, you can memoize the entire table body to massively improve render performance.

    Table Body Memoization Breaks the Following Features:

    density toggle, column hiding, column resizing, column reordering, column pinning, row expanding, row selection, filtering (internal client-side), pagination (internal client-side), searching (internal client-side), sorting (internal client-side), row virtualization
    None of these features will work with table body memoization because the entire table body is memoized. The table is essentially "frozen" at the first render.

    Features That Should Still Work with Table Body Memoization:

    manual server side sorting, pagination, filtering
    const table = useMantineReactTable({
    columns,
    data,
    enableColumnActions: false, //no need for column actions if none of them are enabled
    enableColumnFilters: false, //filtering does not work with memoized table body
    enableDensityToggle: false, //density does not work with memoized table body
    enableGlobalFilter: false, //searching does not work with memoized table body
    enableHiding: false, //column hiding does not work with memoized table body
    enablePagination: false, //pagination does not work with memoized table body
    enableSorting: false, //sorting does not work with memoized table body
    memoMode: 'table-body', // memoize table body to improve render performance, but break all features
    })

    Static Memoized Table

    ErnaHaag8371 Legros MountainLeonportWyoming
    JudyKoepp88662 Nelda CovesFarmington HillsAlaska
    CarmineAdams543 Herzog MountEast EleanoraviewTexas
    NeomaHettinger570 Mason CourseJeniferhavenNew Jersey
    HuldaHauck859 Kilback RidgesAzusaGeorgia
    GregoryBayer900 Emely ShoresMinnetonkaMissouri
    EdgardoKlocko64056 Malachi StationKautzervilleNew Hampshire
    FrancescaO'Hara84041 Kaleb ClubLake AlizeMassachusetts
    JedediahMcGlynn64073 Lynch BurgSouth TitusTexas
    AriannaWest9007 Gottlieb CliffsRockwallIllinois
    LizzieGrant359 Kristy SquareNorth ConradfortKentucky
    HobartHarris696 Grant LockAnahibergArizona
    BaileyKessler31389 Gerhard MeadowBirminghamNew Hampshire
    MedaDenesik2454 Shana PlainsBradtkelandIllinois
    CruzPurdy761 Boyer VistaBolingbrookArizona
    AbdulLeuschke7263 Maynard GreensPort JazmyneMaine
    AliaYost40402 Fahey NeckLehnerstadLouisiana
    MaribelJohns093 Alvis LightsPort LeathaburyPennsylvania
    BertrandPagac660 Smith CanyonWest CraigFlorida
    BennieLueilwitz04589 Simonis CircleKozeycesterTennessee
    AdelleWiza90890 Chelsie ManorsKuhlmanvilleOklahoma
    RosendoSkiles293 Barry RestGuiseppeboroMaine
    AnahiHowell844 Marilyne RoadKipportArkansas
    WilbertCummings5031 Chandler CenterWest FlorenceConnecticut
    DaphneReichert0415 Ratke JunctionTroyOklahoma
    VladimirLesch73073 Elinor VilleWest HopeMichigan
    JaydeShields4424 Zane GlensAuersideFlorida
    JennieReichert007 Zboncak LightAlyciahavenDelaware
    LeilaniRohan16737 Elta RoadsOsinskichesterAlabama
    EmerySchultz40078 Lolita OvalWauwatosaOregon
    AishaBosco466 Crist CovesNorth HenrietteConnecticut
    ZitaMraz788 Malinda PlazaEast JaydaWisconsin
    KelvinWill07225 Kub RueVacavilleWyoming
    SalmaHowe724 Marvin LakesWest AlanaviewIndiana
    MayBraun1700 Gerlach RouteFort CarsonAlabama
    HelenaSenger05454 Mills ViewFort KiarramouthTexas
    SallieWintheiser645 O'Conner PlaceKihnlandWyoming
    SydniMcGlynn124 Brock BranchFort JerelMaryland
    GennaroCarroll58234 Runolfsson MountainNikolascesterMaine
    SidneyKuvalis186 Donavon CornersWest MarcellusfortTexas
    TedO'Hara47585 Halie HarborsLake KyleMichigan
    JeffreyWiegand77672 Kilback CurveWest JazminboroUtah
    GeoMarks122 Misty TraceLouveniasteadMichigan
    JaydeCrooks019 Garnet PassageCroninfieldDelaware
    ZulaKuphal865 Dach StravenueFraminghamNorth Carolina
    KatarinaLuettgen69556 Jayden SpringsFreemanchesterNew Mexico
    JabariBarrows988 Halvorson HillsWest AlessandraportNew Jersey
    AurelieKohler0568 Shields ManorsLakewoodMaryland
    NelleSauer21492 Huels WalkCitrus HeightsNorth Carolina
    NatKonopelski50202 Jovan UnderpassCornellsideVermont
    JadaGraham561 Samson VistaPort ToneyviewLouisiana
    LaurianneSawayn247 Tremblay RapidVancevilleIdaho
    ShemarKirlin7049 Skiles FieldNorth DudleyAlaska
    EdnaBrakus899 Edd CrossingNew JadynTexas
    LillyYost085 Milton VistaLindatonLouisiana
    ClemmieHaley1242 Chesley GreensSmyrnaHawaii
    RobbBernhard717 Enrique VillageGiovannimouthIdaho
    AdrainWill711 Alycia CornerEast MyraSouth Dakota
    MadelynnVolkman20823 Marcos MountainRunolfsdottircesterWisconsin
    WinifredChamplin172 Daisy MillNorth PatsyhavenMontana
    CoySchowalter890 Alverta PlazaHadleyfortWisconsin
    MaryseBeer4664 Stefan CirclesLake IssacNew Hampshire
    NoreneJacobi52793 Hegmann IsleErieAlaska
    JohnathonBarton253 Cayla DaleBlandasideFlorida
    RamiroLang099 Garth StationSpringfieldKansas
    KristofferGrady0916 MacGyver GatewayEast LouArkansas
    JaunitaHills4887 Phyllis NeckSouth IsaiahmouthOhio
    NikolasSchowalter285 Stanton LockNorth JonathonGeorgia
    AnsleyWolff505 Jerde MountainsSouth BrandiPennsylvania
    MaudHegmann09899 Mohr ShoresErinfortAlaska
    SheaKohler2215 Angela ValleyCletatownKentucky
    FernandoShields25912 Jaren NeckCheyenneMississippi
    KiraWilkinson33035 Otilia MissionLake KareemKentucky
    WilfordMonahan27850 Chloe LaneNyafortNorth Dakota
    JackelineSchamberger925 Anjali RowKiehnmouthKentucky
    GersonWyman51420 Jakubowski IslandShanyboroWashington
    KenMedhurst55814 Volkman WaysNew MarleysideAlabama
    EdgardoDavis4098 Boehm MountainLake AdityaburghAlaska
    ConcepcionHaag5306 Ludie PortLake DelaneytonNew Mexico
    NikitaAdams071 Nick RoadsPort JadaMichigan
    NorbertoGreen578 Noel FallsGutkowskiburghNorth Carolina
    MatildeKerluke3555 Nolan CommonLake ElainaMontana
    VerdaBartoletti14524 Hand SpringsDomenicshireAlabama
    AdeliaEmmerich6461 Ellsworth JunctionsEast BridgetteMassachusetts
    RomaAnkunding038 Rutherford BypassCreminlandHawaii
    BentonWill027 Lakin UnionPort MelanyNebraska
    JaysonRosenbaum696 Abshire OrchardPalm Beach GardensMississippi
    AbbeyHoeger308 Hirthe BypassLakelandMassachusetts
    StanDuBuque54220 Howe TrailNew VirgilNew Hampshire
    ThelmaMarvin8316 Anissa SkywayBellevueTexas
    AdelaMosciski7175 Scarlett InletMalloryfurtWyoming
    NarcisoHessel2582 Telly SpursDublinGeorgia
    JazlynAnderson7113 Kelley WallEast VitoGeorgia
    EthaHudson305 Kiera CommonEast MiracleMichigan
    MoniqueKuhic65159 Wava LodgeOklahoma CityMontana
    CieloMills07954 West RoadSunrise ManorWyoming
    LlewellynFrami90812 Gorczany JunctionMitchellvilleMissouri
    CierraKing0797 Reinger FortConncesterMassachusetts
    FrancescoSchuppe5247 Lockman DaleLake JacintocesterOhio
    ValentinaStoltenberg3049 Oberbrunner IsleOsinskifieldMontana
    CarmelDooley6079 Madisyn CrestRivertonNebraska
    BettyeLittle14055 Bette ViewsNew OlenArizona
    KimJohnston9157 Gleason IslandsNorth TaniafieldMaine
    RebekahHackett20891 Darrion CurveRyleyhavenArizona
    GuyBrown4856 Rohan FordFayboroughFlorida
    GusWehner533 Hayes ForgeRancho Palos VerdesOregon
    HowellHudson6079 Treva FallsLake DavidVermont
    KeshawnGrimes0865 Krystina LightAmosfurtLouisiana
    LaurettaBartoletti48011 Howe ShoreLake KhalidAlaska
    GaetanoKlein8433 Wilkinson ForksSchaefermouthMassachusetts
    JarredWyman7308 O'Reilly SquaresFort AlbachesterNew Hampshire
    KaitlynCassin252 Parisian LocksNorth AugustusvilleVirginia
    CydneyGleichner072 Gretchen WalksYoshikoshireMaryland
    DaphneKoelpin21942 Agustina ForgeLake DarrickVermont
    JordaneBrekke1187 Ervin DamUllrichbergHawaii
    SamanthaFeest0407 Jaunita RanchGreeleyUtah
    AustinSpencer4251 Maureen PlainAufderharburyNorth Carolina
    ThoraAnkunding1197 Huel CliffsShorelineMaryland
    RudyMertz9903 Randall MissionMelyssaboroughMaryland
    EbonyKeebler37823 Larkin WayDeefurtMichigan
    MurielRuecker12922 Summer ThroughwayMantecaIllinois
    WernerBerge536 Kohler TraceNorth AmarafortLouisiana
    MaceyLemke50890 Blanca FordsHeidenreichfieldNebraska
    AlizaJaskolski8679 Yazmin TraceAshevilleOhio
    LaronPfeffer8601 Lang CornersLaurianecesterWyoming
    SamsonDicki99371 Dickens VistaAllenehavenOhio
    DesireeReichert763 Ora PinesKhalilmouthVermont
    TateStamm30509 Boyle HarborsEast QueenGeorgia
    KimBeer825 Norberto ExtensionJaedencesterNew Jersey
    VivianeKoelpin722 Mueller CrestArcadiaMassachusetts
    MilanO'Keefe013 King PrairieSandyfurtNebraska
    KameronHettinger163 Virginia ForkNew ZorachesterWyoming
    ChetReilly0459 Haven GlensGwendolynhavenKentucky
    RashawnBlanda17035 Ernest LaneMargareteboroughWest Virginia
    NathenPollich9604 Harley StreetHackettviewAlabama
    ModestaWindler08804 Walsh LakeHannahshireTexas
    LucasSenger28874 Gerlach CrossingStrongsvilleAlaska
    MathildeWehner141 Medhurst ExtensionsNew PaulTexas
    EmmyRunolfsson31588 Brenna HollowNew BrigitteVirginia
    AraRoberts62361 Dimitri IslandAmarilloIndiana
    FridaCrona9178 Susana CrestVergieburghKentucky
    KenyattaLittel93163 Charley SummitKansas CityArizona
    KielCarroll696 Mellie PikeSouth GisselleNew Hampshire
    SkylarWindler312 Haylee RowLake LinaTennessee
    MyrtisJones04067 Marquardt LocksNorth DejaArizona
    JanisRussel0923 Heaney TrailRiverviewNorth Dakota
    GeovanyBatz6789 Madelynn MeadowFort MeaganburghIdaho
    KellenFlatley55886 Torphy TurnpikeBrekkeboroughWisconsin
    AudieCronin612 Gladyce InletNorth HassanOklahoma
    AlexaneKilback732 Magali HollowLefflersteadMassachusetts
    BellaKris3295 Yessenia ExpresswayBiloxiIndiana
    GraysonCorwin437 D'Amore HillBeierlandKansas
    LoganGislason53779 Reichel RapidGideonshireNebraska
    MaiyaLesch6999 Thalia PrairieNorth MichealVirginia
    AylinLeffler32399 Thurman IslandLake AronMissouri
    SheilaBorer1169 Gabrielle SpringsAnnamaecesterKentucky
    RyleeAnkunding194 Buckridge HillSouth BertaOhio
    CoreneGrimes641 Monahan PinesEast PrincefurtIllinois
    1
    import { useMemo } from 'react';
    2
    import { MantineReactTable, type MRT_ColumnDef } from 'mantine-react-table';
    3
    import { Title } from '@mantine/core';
    4
    import { data, type Person } from './makeData';
    5
    6
    export const Example = () => {
    7
    const columns = useMemo<MRT_ColumnDef<Person>[]>(
    8
    () => [
    9
    {
    10
    accessorKey: 'firstName',
    11
    header: 'First Name',
    12
    },
    13
    {
    14
    accessorKey: 'lastName',
    15
    header: 'Last Name',
    16
    },
    17
    {
    18
    accessorKey: 'address',
    19
    header: 'Address',
    20
    },
    21
    {
    22
    accessorKey: 'city',
    23
    header: 'City',
    24
    },
    25
    {
    26
    accessorKey: 'state',
    27
    header: 'State',
    28
    },
    29
    ],
    30
    [],
    31
    );
    32
    33
    return (
    34
    <MantineReactTable
    35
    columns={columns}
    36
    data={data}
    37
    enableBottomToolbar={false} //no need for bottom toolbar if no pagination
    38
    enableColumnActions={false} //no need for column actions if none of them are enabled
    39
    enableColumnFilters={false} //filtering does not work with memoized table body
    40
    enableDensityToggle={false} //density does not work with memoized table body
    41
    enableGlobalFilter={false} //searching does not work with memoized table body
    42
    enableHiding={false} //column hiding does not work with memoized table body
    43
    enablePagination={false} //pagination does not work with memoized table body
    44
    enableSorting={false} //sorting does not work with memoized table body
    45
    enableStickyHeader
    46
    memoMode="table-body" // memoize table body to improve render performance, but break all features
    47
    mantineTableContainerProps={{ sx: { maxHeight: '500px' } }}
    48
    renderTopToolbarCustomActions={() => (
    49
    <Title order={4}>Static Memoized Table</Title>
    50
    )}
    51
    />
    52
    );
    53
    };
    54
    55
    export default Example;
    1
    import { useMemo } from 'react';
    2
    import { MantineReactTable } from 'mantine-react-table';
    3
    import { Title } from '@mantine/core';
    4
    import { data } from './makeData';
    5
    6
    export const Example = () => {
    7
    const columns = useMemo(
    8
    () => [
    9
    {
    10
    accessorKey: 'firstName',
    11
    header: 'First Name',
    12
    },
    13
    {
    14
    accessorKey: 'lastName',
    15
    header: 'Last Name',
    16
    },
    17
    {
    18
    accessorKey: 'address',
    19
    header: 'Address',
    20
    },
    21
    {
    22
    accessorKey: 'city',
    23
    header: 'City',
    24
    },
    25
    {
    26
    accessorKey: 'state',
    27
    header: 'State',
    28
    },
    29
    ],
    30
    [],
    31
    );
    32
    33
    return (
    34
    <MantineReactTable
    35
    columns={columns}
    36
    data={data}
    37
    enableBottomToolbar={false} //no need for bottom toolbar if no pagination
    38
    enableColumnActions={false} //no need for column actions if none of them are enabled
    39
    enableColumnFilters={false} //filtering does not work with memoized table body
    40
    enableDensityToggle={false} //density does not work with memoized table body
    41
    enableGlobalFilter={false} //searching does not work with memoized table body
    42
    enableHiding={false} //column hiding does not work with memoized table body
    43
    enablePagination={false} //pagination does not work with memoized table body
    44
    enableSorting={false} //sorting does not work with memoized table body
    45
    enableStickyHeader
    46
    memoMode="table-body" // memoize table body to improve render performance, but break all features
    47
    mantineTableContainerProps={{ sx: { maxHeight: '500px' } }}
    48
    renderTopToolbarCustomActions={() => (
    49
    <Title order={4}>Static Memoized Table</Title>
    50
    )}
    51
    />
    52
    );
    53
    };
    54
    55
    export default Example;
    View Extra Storybook Examples
    You can help make these docs better! PRs are Welcome
    Using Material-UI instead of Mantine?
    Check out Material React Table