plotly/react-pivottable

"Select All" for first time leads to Uncaught TypeError: Cannot convert undefined or null to object

keyemkey opened this issue · 1 comments

Hi, issue is reproducible on live demo

Repro steps:

  1. Start fresh demo
  2. Select aggregator (for example, Paty Size)
  3. Click select All (I know that All already selected, but I am persistent)
  4. Notice exception
    TypeError: Cannot convert undefined or null to object
(anonymous function)
../node_modules/immutability-helper/index.js:141
  138 | $unset: function(value, nextObject, spec, originalObject) {
  139 |   invariantSpecArray(value, '$unset');
  140 |   value.forEach(function(key) {
> 141 |     if (Object.hasOwnProperty.call(nextObject, key)) {
  142 |       if (nextObject === originalObject) nextObject = copy(originalObject);
  143 |       delete nextObject[key];
  144 |     }

Looks like issue is pretty simple, but in our case it is annoying.
Possibly related to #67

I've had the same problem. Because I dropped {...this.state} when declared component:

<PivotTableUI
                        data={dataArray}
                        cols={["Col1"]}
                        rows={["Row1"]}
                        onChange={s => this.setState(s)}
                    />

Obviously this couldn't work because changed PivotTableUI state goes to nowhere.
So I had to change it to (notice the absence of data attribute):

<PivotTableUI
                        cols={["Col1"]}
                        rows={["Row1"]}
                        onChange={s => this.setState(s)}
                        {...this.state}
                    />