Skip to content
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

Sometimes the options don't load #60

Open
mledwards opened this issue Mar 2, 2021 · 1 comment
Open

Sometimes the options don't load #60

mledwards opened this issue Mar 2, 2021 · 1 comment

Comments

@mledwards
Copy link

I stripped the code down to what you see below, and 10% of the time the options don't load on page load. Any ideas?

import React from "react";
import ReactGlobe from "react-globe";

function Globe() {

  return (
    
      <ReactGlobe
        height={"100vh"}
        options={{
          globeGlowColor: "#0A69FB",
          globeCloudsOpacity: 1.0,
        }}
        width={"100vw"}
      />
  );
}

export default Globe;

@mledwards
Copy link
Author

My workaround to this was to use useEffect when the globe object was available, and also use a kinda yucky setTimeout.

// Only run once the globe object exists
  useEffect(() => {
    if (!globe) {
      return;
    }

    // Wait a second and re-add the same options
    setTimeout(() => {
      globe.updateOptions(options);
    }, 1000);
  }, [globe]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant