Skip to content

[Again] Uncaught TypeError: onSort is not a function #1211

@mazzalab

Description

@mazzalab

Hi all,
I know this is a duplicate of #652 but it seems that that issue was closed without providing a solution to the problem.

I am using "react-bootstrap-table-next": "^3.3.3" and my simple Component ha this constructor:

constructor(props) {
        var _isMounted = false;

        super(props);
        this.state = {
            data: [{ 'id': 1 }],
            columns: [{
                dataField: 'id',
                text: 'Product IDs'
            }],
            rowCount: 10
        }
    }

You can see that I save data and columns in the component state, which I finally update in

componentDidMount() {
        this._isMounted = true;

        fetch('http://127.0.0.1:5000/')
            .then(response => response.json())
            .then(data => {
                var sorted_header = this.formatHeader(data);

                if (this._isMounted) {
                    this.setState({ columns: sorted_header });
                    this.setState({ data: data });
                }
            });
    }

the "formatHeader" method simply formats the header of the table with things like:

const sorted_header = [{
            dataField: 'id',
            text: 'Product ID',
            sort: true
        }, {
            dataField: 'user',
            text: 'User',
            filter: textFilter(),
            style: {
                fontStyle: 'italic',
            },
            sort: true
        }
       ...

whenever I click on the header up/down arrow to sort one of these columns I get the wrror in object that points to the internal file "header-cell.js:123"
(this error in attachment)

What to do?
thanks

Annotation 2019-12-26 211120

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions