Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React table not displaying data

so im using react-table library to display a tree grid table with mocked data but it isn't appearing like it should and it shows that there's one item on the table.

import React, { Component } from 'react';
import ReactTable from "react-table";
import 'react-table/react-table.css'

export default class TestTable extends Component {

    state = {
        data: [{
                actionNo: "1",
                action: "--",
                productService: "Mobile Contract",
                qty: 1,
                startDate: Date.now(),
                endDate: Date.now(),
                account: 11111111,
                mobileNo: 9111111,
                amount: "--",
                status: "Error"
            }]
    }
    render() {
        const { data } = this.state;
        console.log(data);

        const columns = [{
            Header: 'Action No.',
            accessor: 'actionNo'
        }, {
            Header: 'Action',
            accessor: 'action',
        }, {
            acessor: 'productService',
            Header: 'Product/Service',
        }, {
            acessor: 'qty',
            Header: 'Qty.',
        }, {
            acessor: 'startDate',
            Header: 'Start Date',
        }, {
            acessor: 'endDate',
            Header: 'End Date',
        }, {
            acessor: 'account',
            Header: 'Account',
        }, {
            acessor: 'mobileNo',
            Header: 'Mobile No.',
        }, {
            acessor: 'amount',
            Header: 'Amount.',
        }, {
            acessor: 'status',
            Header: 'Status',
        }]

        return (
            <ReactTable
                data={data}
                columns={columns}
                pivotBy={["actionNo"]}
                defaultPageSize={10}
                showPagination={false}
                resizable={false}
                noDataText="No Data!"
                className="-striped -highlight"
            />
        );
    }
}

This is the result of the snippet above enter image description here:

Soon i'll be using real data from a database but i need to test this out before messing around with micro service integration.

like image 514
Tomas Duarte Avatar asked Mar 05 '23 07:03

Tomas Duarte


1 Answers

It's a typo. Please try using 'accessor' instead of 'acessor'.

like image 109
Long TM Avatar answered Mar 11 '23 14:03

Long TM