-
-
Notifications
You must be signed in to change notification settings - Fork 268
Updating PivotTableUI prop does not always force a re-render of child renderer #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm not sure I'm following exactly what you're trying to do... are you able to provide a minimal example piece of code I can play with? One thing I wonder is if you are making immutable changes to |
It sounds like you understand what's going on, even though I don't. What do you mean by "is the identity of the layout object changing when you change one of its keys?" I'm guessing this is related to plotly/plotly.js#2389, and, hence, the react-plotly basic props warning but not sure. Still, here's a simplified version of my code, with some bits excluded (such as data, actual layout content, etc.). The PivotTableUI component:
where
and:
The issue is that after the data is pivotted (i.e., by updating state.pivotProps in this.onChangePivot), the PlotlyComponent no longer responds to layout changes. Unless I change the key. It could be that changing the key is the right way to do this (i.e., start from scratch), but not sure. It's also possible (likely?) this is a Plotly issue rather than a PivotTableUI issue. Fyi, here's a screenshot of my goal (again: something like Plotly's own plot designer, but much simpler): |
Uh oh!
There was an error while loading. Please reload this page.
I'm trying to create what amounts to my own version of Plotly's react-chart-editor. In doing so, I'm passing a layout prop to my component, which I then include in my PlotlyRenderer.js for the final render. Pretty straightforward. However, updates to layout (changes in chart title, etc.) propagate only to the first PivotTableUI configuration. If I change the configuration (pivot the data), subsequent changes to layout do not propagate to the child plot renderer.
My solution to this is to add a key to the main PivotTableUI component, consisting of the stringified version of the layout object. I.e.,
<PivotTableUI key={JSON.stringify(layout)} ...otherProps />
. This works, but I'm not sure if it's correct. If it is correct, perhaps this should be done within the PivotTableUI component itself? An alternative might be to use componentWillReceiveProps and shouldComponentUpdate?The text was updated successfully, but these errors were encountered: