Plot does not re-render on state change


#1

I have addressed this question here, but then I realized that it is likely the problem with Plotly, not React.

I have a component that changes view from line plot to table on checkbox change.

Checkbox is handled through state:
handleCheckbox = e => { const plot = e.target.checked; this.setState({ plot }) }

Then, in return section, rendering the plot is based on this logic: {this.state.plot ? plot : table}

The problem is: when I just switch the checkbox, everything works fine, but if I first interact with the plot (choose traces) and then try to switch to the table, nothing happens and the following error occurs:
Error while plotting: TypeError: Cannot read property 'uid' of undefined at getTraceIndexFromUid (plotly.js:137058) at applyUIRevisions (plotly.js:137152) at Object.exports.react (plotly.js:137256) at factory.js:142

Interface pic with plot
interface pic with table
Gif showing the behavior
Codepen with full component code (just in case)
Shortened code (as minimal example) is shown in this question