Chart type scatter3d make onClick loop when calling history.push inside it
See original GitHub issueUsing Plot inside a Router with type “scatter3d” and trying to use history inside onClick (only if it doesn’t unmount the Plot Component) make onClick loop after a first click.
Minimal example:
import Plot from "react-plotly.js";
import { BrowserRouter, Route, useHistory } from "react-router-dom";
function Chart3D() {
const history = useHistory();
return (
<Plot
onClick={() => {
console.log("This will be printed a lot");
history.push("/");
}}
data={[
{
x: [1],
y: [1],
z: [1],
type: "scatter3d",
},
]}
/>
);
}
export default function App() {
return (
<BrowserRouter>
<Route path="/" component={Chart3D} />
</BrowserRouter>
);
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Why with history.push onClick function I have two components ...
Both these components match and render on the Routes.TrainDetails.path (i.e. "/trains/:idTrain" ) path. Since both are being rendered then ...
Read more >How to pass additional data while redirecting to a route in React
Photo by Burst on Unsplash. In this article, we will see how we can pass extra data while redirecting to a different route....
Read more >Matplotlib.pdf
Note: Matplotlib depends on non-Python libraries. ... Use the bar() function to make bar charts, which includes ... on GUI event loops.
Read more >Matplotlib - Ole Miss Physics
objects, call methods, set properties, and so on; it should just work. ... provided by matplotlib.pylab which allow the user to create plots ......
Read more >Matplotlib - The University of Texas at Austin
objects, call methods, set properties, and so on; it should just work. ... provided by matplotlib.pylab which allow the user to create plots ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Probably not ? I stopped working on the project where I was needing to do this just a few days after submitting this issue so I don’t have any workaround and didn’t investigate further. But since this issue is still open 15 months after being submitted and the only commit made since is just changing a link in the README, I don’t think this package is actively maintained and it would probably be safer to use something else.
Which is why this repo is so quiet - it’s a thin wrapper around plotly.js so most issues that pop up are actually issues in plotly.js itself. @Eyon42 if you’d be able to reproduce the problem as a codepen or such using plotly.js directly and post it at https://github.com/plotly/plotly.js/issues, that would help us a lot to find a solution.