react-data-grid icon indicating copy to clipboard operation
react-data-grid copied to clipboard

Failed propType: Required prop `isScrolling` was not specified in…

Open zedrdave opened this issue 10 years ago • 6 comments

I'm submitting a ... (check one with "x")

[x ] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/adazzle/react-data-grid/blob/master/CONTRIBUTING.md

Example code with latest version of React and the component yields two warnings:

[Error] Warning: Failed propType: Required prop `isScrolling` was not specified in `Row`. Check the render method of `Canvas`.
[Error] Warning: Failed propType: Required prop `isScrolling` was not specified in `Cell`. Check the render method of `Row`.

I don't see any mention in the doc of how to set this property appropriately (in the type of code the examples use)…

zedrdave avatar Nov 16 '16 07:11 zedrdave

Looks like the getInitialState for ViewportScrollMixin needs to be updated to have {isScrolling: false}

aschonfeld avatar Nov 21 '16 14:11 aschonfeld

@aschonfeld Can you please clarify? I am also facing the same issue. As @zedrdave said, none of the examples in the docs talk about any components other than ReactDataGrid. Not sure how we should use Row, Cell etc.

anujit avatar Nov 24 '16 20:11 anujit

I was just stating what would solve this problem. I'm not sure if that is the correct business logic or not, but from what I saw it was the most logical thing to do.

I encounter this problem is when I am using Draggable from react-data-grid/addons.

<Draggable.Container>
  <ReactDataGrid
    ref="selectedNodesGrid"
    columns={selectedNodesColMetadata}
    rowGetter={this.getSelectedNode}
    rowsCount={this.state.selectedNodes.length}
    minHeight={200}
    rowActionsCell={Draggable.RowActionsCell}
    rowRenderer={<RowRenderer onRowDrop={this.onReorder} />}
    rowSelection={{
      showCheckbox: false,
      selectBy: {keys: {rowKey: 'id', values: []}},
    }}
    emptyRowsView={() => <div className="placeholder">No nodes selected.</div>} />
</Draggable.Container>

When the ViewportScrollMixin is added to Viewport its getInitialState method is not setting isScrolling to false. Here is the code currently:

  getInitialState(): ViewportScrollState {
    return this.getGridState(this.props);
  }

I believe it should be something like the following:

  getInitialState(): ViewportScrollState {
    const initalState = this.getGridState(this.props);
    initialState.isScrolling = false;
    return false;
  }

This makes sense to me since when you first instantiating the component usually it is not being scrolled. You don't want to make this update within getGridState because it is called elsewhere.

aschonfeld avatar Nov 25 '16 21:11 aschonfeld

http://adazzle.github.io/react-data-grid/examples.html#/one-million-rows

when i was trying to replicate this issue , i found the same error , is there a fix for it ?

Failed prop type: Required prop isScrolling was not specified in Cell. Failed prop type: Required prop isScrolling was not specified in Row.

Kamaraju333 avatar Nov 30 '16 21:11 Kamaraju333

@zedrdave did you find a solution? Any fix for this?

Princezhm avatar Jan 09 '17 17:01 Princezhm

Get the grid rendered. But the same warnings are shown in console.

  • Warning: Invalid argument supplied to oneOf, expected an instance of array.
  • Warning: Failed prop type: The prop isScrolling is marked as required in Row, but its value is undefined
  • Warning: Cell: ref is not a prop. Trying to access it will result in undefined being returned. If you need to access the same value within the child component, you should pass it as a different prop.
  • Warning: Failed prop type: The prop isScrolling is marked as required in Cell, but its value is undefined._
import React,  {Component} from 'react';
import ReactDataGrid from 'react-data-grid';

export default class GridExample extends Component {
    constructor(props){
        super(props);

        this.createRows=this.createRows.bind(this);
        this.randomDate=this.randomDate.bind(this);
        this.rowGetter=this.rowGetter.bind(this);
        this.handleRowUpdated=this.handleRowUpdated.bind(this);

        this.state = {
            rows: this.createRows(16),
            isScrolling: false
        }
    }

    //helper to generate a random date
    randomDate(start, end) {
        return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime())).toLocaleDateString();
    }

    //helper to create a fixed number of rows
    createRows(numberOfRows){
        let _rows = [];
        for (let i = 1; i < numberOfRows; i++) {
            _rows.push({
                id: i,
                task: 'Task ' + i,
                complete: Math.min(100, Math.round(Math.random() * 110)),
                priority : ['Critical', 'High', 'Medium', 'Low'][Math.floor((Math.random() * 3) + 1)],
                issueType : ['Bug', 'Improvement', 'Epic', 'Story'][Math.floor((Math.random() * 3) + 1)],
                startDate: this.randomDate(new Date(2015, 3, 1), new Date()),
                completeDate: this.randomDate(new Date(), new Date(2016, 0, 1))
            });
        }

        return _rows;
    }

    rowGetter(rowIdx){
        return this.state.rows[rowIdx]
    }

    handleRowUpdated(e){
        //merge updated row with current row and rerender by setting state
        let rows = this.state.rows;
        Object.assign(rows[e.rowIdx], e.updated);
        this.setState({rows:rows});
    }

    render(){
        //Columns definition
        var columns = [
            {
                key: 'id',
                name: 'ID'
            },
            {
                key: 'task',
                name: 'Title'
            },
            {
                key: 'priority',
                name: 'Priority'
            },
            {
                key: 'issueType',
                name: 'Issue Type'
            },
            {
                key: 'complete',
                name: '% Complete'
            },
            {
                key: 'startDate',
                name: 'Start Date'
            },
            {
                key: 'completeDate',
                name: 'Expected Complete'
            }
        ]

        return(
            <ReactDataGrid
                columns={columns}
                rowGetter={this.rowGetter}
                rowsCount={this.state.rows.length}
                minHeight={500}
                onRowUpdated={this.handleRowUpdated}
                isScrolling={this.state.isScrolling}/>
        )
    }
}
"dependencies": {
    "react": "^15.4.0",
    "react-data-grid": "^1.0.81",
    "react-dom": "^15.4.0",
 }

Note: Grid style is included

emilium avatar Jan 10 '17 13:01 emilium