4

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.

3
  • have you tried the simplest config like: <ReactTable data={data} columns={columns} defaultPageSize={10} className="-striped -highlight"/>? Commented Oct 1, 2018 at 9:43
  • Edited your code and added constructor method to initialize the state. Commented Oct 1, 2018 at 9:46
  • @ChetanSinghal your edit brings nothing. he already is instantiating his state correctly via the class properties transform. Commented Oct 1, 2018 at 9:54

1 Answer 1

7

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

Sign up to request clarification or add additional context in comments.

2 Comments

great, i'm just found the inconsistent between accessor and acessor by looking your answer. lol.
Thank you. I wasted over an our scratching my head till this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.