From 5350c8c0ad727d9a94e67bda633eaa2fdd5fce5a Mon Sep 17 00:00:00 2001 From: Travis DePrato <773453+travigd@users.noreply.github.com> Date: Mon, 23 Aug 2021 00:21:39 -0700 Subject: [PATCH] Warning if using frozen props Adds a warning if the passed in data prop is `Object.freeze`'d. This is important since several React state managers return values that are frozen (in my case, Apollo). Currently, this just causes the plot to completely fail to render and gives no indication as to what's wrong. --- src/factory.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/factory.js b/src/factory.js index 9911014..e265cd6 100644 --- a/src/factory.js +++ b/src/factory.js @@ -107,6 +107,10 @@ export default function plotComponentFactory(Plotly) { componentDidMount() { this.unmounting = false; + + if (Object.isFrozen(this.props.data)) { + console.warn("react-plotly.js expects mutable data and layout props"); + } this.updatePlotly(true, this.props.onInitialized, true); }