-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
Modernize react-plotly.js and support plotly.js-dist-min v2 #333
base: master
Are you sure you want to change the base?
Conversation
@brammitch It looks like very valuable PR, any plans merging it? |
I hope so! If @alexcjohnson or any other maintainer wants to review this PR, I'd be happy to discuss further changes, rework, or testing. |
This would be a major upgrade. Can we get this merged? |
@alexcjohnson would be nice to get this merged, is anyone able to look at it? |
Thanks @brammitch and apologies for the delay - @archmoj would you be able to review this? |
@brammitch great PR 🎖️ On another note - please use |
Thanks for the feedback @archmoj! The vulnerability has been resolved. I updated the "name": "react-plotly.js",
"version": "3.0.0",
"engines": {
"node": ">= 18"
}, I also updated the README references to |
Bumping @archmoj -- this would be helpful in my project :) |
LGTM. |
As long as it's tested with RCE and CS, it's all good. |
@dmt0 you may feel differently, but personally I wouldn't worry about CS prior to publishing this. Testing with RCE should be sufficient to surface most potential issues with CS, then if any issues were to arise in CS we could either hold it to v2.x or address them from the CS side. @archmoj @dmt0 I'll leave that testing to you two, this looks good from my side. Thanks again @brammitch! |
Unfortunately
|
I'm looking at it now. RCE has a hard dependency on |
Made some progress, but still don't have RCE working. In local In local Checking But now there's a webpack error when running resolve: {
alias: {
'react-dom': '@hot-loader/react-dom',
'react/jsx-runtime': require.resolve('react/jsx-runtime'),
},
}, Now RCE will build, storybook works, all tests pass, but |
Does RCE work after 500a343? |
It didn't for me. |
}, [gd, handleUpdate, props.onInitialized, resizeHandler, updatePlotly, useResizeHandler]); | ||
|
||
// componentDidUpdate | ||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that this useEffect
is what iscausing the problem with RCE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original componentDidUpdate
function compared frames, layout, data, config, and revision.
I did not code to that specific logic because I expected useEffect to handle it. When RCE starts, the updatePlotly
callback is called over and over again. I tried implementing the componentDidUpdate
logic in the useEffect
:
// componentDidUpdate
useEffect(() => {
let shouldUpdate = true;
// frames *always* changes identity so fall back to check length only :(
const numPrevFrames = prevProps?.frames?.length ?? 0;
const numNextFrames = props.frames?.length ?? 0;
const dataChanged = !isEqual(prevData, data);
const layoutChanged = !isEqual(prevProps?.layout, props.layout);
const configChanged = !isEqual(prevProps?.config, props.config);
const numFramesChanged = numNextFrames !== numPrevFrames;
const figureChanged = dataChanged || layoutChanged || configChanged || numFramesChanged;
const revisionDefined = prevProps?.revision !== void 0;
const revisionChanged = prevProps?.revision !== props.revision;
if (!figureChanged && (!revisionDefined || (revisionDefined && !revisionChanged))) {
shouldUpdate = false;
}
if (shouldUpdate && props.onUpdate) {
updatePlotly(props.onUpdate);
}
}, [data, prevData, prevProps, props, updatePlotly]);
but this causes RCE to error due to "too many re-renders".
I would still like to revisit this and dive deeper into the issues my PR has with RCE, but my day job is keeping my busy at the moment. If anyone else has cycles to improve this PR to get it compatible with RCE, I'd welcome the collaboration. |
plotly.js-dist-min
v2tsup
vitest
and@testing-library/react
(88% coverage); replacesenzyme