question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Chart type scatter3d make onClick loop when calling history.push inside it

See original GitHub issue

Using 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:open
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
lowczarccommented, Jun 5, 2022

any solution to this?

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.

1reaction
alexcjohnsoncommented, Jun 8, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found