Giter Site home page Giter Site logo

Code breaking with webpack 2 about table HOT 17 CLOSED

atkawa7 avatar atkawa7 commented on August 18, 2024 3
Code breaking with webpack 2

from table.

Comments (17)

tannerlinsley avatar tannerlinsley commented on August 18, 2024 1

Fixed in 505db8d ([email protected])

from table.

tannerlinsley avatar tannerlinsley commented on August 18, 2024 1

Thanks for finding this bug!

from table.

tannerlinsley avatar tannerlinsley commented on August 18, 2024

Can you post your props and data?

from table.

atkawa7 avatar atkawa7 commented on August 18, 2024

here is the function that creates columns

function getColumns(route) {
const columns = [  'date',
    'total_plays',
    'total_views',
    'total_time',
    'title',
    'plays'];
    var headers = columns.map(function(header) {
        if (header === 'total_time') {
            return {
                header: titleCaps(header),
                accessor: header,
                render: props => (
                    <span>
                        {convertHours(parseInt(props.value))}
                    </span>
                )
            };
        } else if (header === 'title') {
            return {header: '#1 Title ', accessor: header}
        } else if (header === 'plays') {
            return {header: '#1 Plays ', accessor: header}
        } else if (header === 'date') {
            return {
                header: titleCaps(header),
                accessor: header,
                render: props => (
                    <span>
                        <Link to={`${route.path}/${props.value}`}>{props.value}</Link>
                    </span>
                )
            };
        } else if (header === 'title') {

            return {
                header: titleCaps(header),
                accessor: header,
                render: props => <span className='number'>{props.value.split(/\s+/).slice(0, 10).join(' ')}</span>,
                sortable: false
            }
        } else {

            return {header: titleCaps(header), accessor: header};
        }

    });
    return headers;
    console.log(headers);
}

from table.

tannerlinsley avatar tannerlinsley commented on August 18, 2024

Looks good to me. What about where you render your table? Maybe set a break point at the line and log some of the variables?

from table.

atkawa7 avatar atkawa7 commented on August 18, 2024

Here is the chart without the table but once I add table it does not work

screenshot from 2017-01-17 20-54-32

from table.

atkawa7 avatar atkawa7 commented on August 18, 2024
var currentColumns = getColumns(route);
return (<ReactTable columns={currentColumns} manual data={this.state.results} pages={this.state.pageNumber} loading={this.state.loading} onChange={this.handlePage.bind(this)} minRows={0} pageSizeOptions={[
                    5,
                    10,
                    20,
                    25,
                    50,
                    100,
                    150,
                    200,
                    250,
                    500
               ]}/>);

from table.

atkawa7 avatar atkawa7 commented on August 18, 2024

In the default constructor

this.state ={
  results: [],
    pageNumber: 1,
    page: 1,
    count: 0,
    next: null,
    previous: null,
    pageSize: 20,
    loading: true,
    ordering: '-date'};

screenshot

from table.

tannerlinsley avatar tannerlinsley commented on August 18, 2024

Set a breakpoint at the error and copy the current internal state and props of the table. Post them here if you can?

from table.

atkawa7 avatar atkawa7 commented on August 18, 2024

Found the error. It is because of this import function. It is not transforming the code. What could be a reason for this

screenshot from 2017-01-17 21-26-42

from table.

tannerlinsley avatar tannerlinsley commented on August 18, 2024

Well that's weird. Very standard import, no?

from table.

dmftuva avatar dmftuva commented on August 18, 2024

export default class SettingsOrgs extends React.Component {

drawTable() {
    var columns = [
        {
            header: 'ID',
            accessor: 'id'
        },
        {
            header: 'Full Name',
            accessor: 'fullname'
        },
        {
            header: 'Inn',
            accessor: 'inn'
        },
    ];

    return (
        <div>
            <ReactTable
                data={this.state.items}
                columns={columns}
            />
        </div>
    )
}

render() {
    return (
           <div className='row expanded'>
                <div className="small-12">
                    {this.drawTable()}
                </div>
            </div>

)
}
}

Uncaught (in promise) TypeError: Cannot read property 'columns' of undefined

from table.

dmftuva avatar dmftuva commented on August 18, 2024

import React,{Component} from 'react'
import ReactTable from 'react-table'

from table.

vladra avatar vladra commented on August 18, 2024

I've just encountered same error, with webpack 1. So it's not only webpack 2 related

Passing columns property to each column solving error, but it's not working like in docs then

from table.

atkawa7 avatar atkawa7 commented on August 18, 2024

How ? @vladra Please give an example?

from table.

tannerlinsley avatar tannerlinsley commented on August 18, 2024

The storybook is working fine with examples similar to yours. Does the Server-side demo work for you?

from table.

tannerlinsley avatar tannerlinsley commented on August 18, 2024

Wait. I think I see the problem. I'll have the fix out in 5 minutes.

from table.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.