turnerniles / react-virtualized-pivot

React Virtualized Pivot
https://turnerniles.github.io/react-virtualized-pivot/
MIT License
107 stars 19 forks source link

TypeError: r.props.data[0].map is not a function #108

Open mitchhankins01 opened 6 years ago

mitchhankins01 commented 6 years ago

Hi,

I'm getting this error when trying to pass in an array of objects in to Pivot, according to the docs this should be possible; and when I pass in an array of arrays Pivot works just fine.

Sample data causing issues:

const data = [

{ name: 'Some Name', age: 'Some Age' },

{ name: 'Some Name', age: 'Some Age' },

{ name: 'Some Name', age: 'Some Age' },

{ name: 'Some Name', age: 'Some Age' },

{ name: 'Some Name', age: 'Some Age' }

];

<Pivot data={data} />

Any help would be greatly appreciated, thanks!

turnerniles commented 6 years ago

Hi @IronCoderXYZ, I'll take a look at this, this weekend!

mitchhankins01 commented 6 years ago

@turnerniles, thanks! I'm trying to render a very large list of data for work and this library seems very promising.

It seems the problem lies with const aggregationDimensions = this.props.data !== undefined ? this.props.data[0].map((item, index) => { return {value: item, label: item}; }) : [];

The code assumes that the first entry in the data array is an array of headers, I'm trying to troubleshoot a bit as well.

mitchhankins01 commented 6 years ago

@turnerniles I fixed the issue with this pull request: https://github.com/turnerniles/react-virtualized-pivot/pull/109