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

Asynchronously added widget not showing up #35

Open
gijo-varghese opened this issue Nov 20, 2018 · 2 comments
Open

Asynchronously added widget not showing up #35

gijo-varghese opened this issue Nov 20, 2018 · 2 comments

Comments

@gijo-varghese
Copy link

gijo-varghese commented Nov 20, 2018

I'm using the widget inside a modal and several other components in a react project. So when the render function executes it could not find the widgets since it's still not added to the dom.

Can I call render function again? If so how is it? Is it the right method?

@gijo-varghese
Copy link
Author

gijo-varghese commented Nov 21, 2018

For now what I've done is:

import habitat from "preact-habitat";
import Root from "./Root";

window.render = () => {
  habitat(Root).render({
    ...
  });
};

// in development, set up HMR:
if (module.hot) {
  require("preact/devtools"); // enables React DevTools, be careful on IE
  module.hot.accept("./Root", () => requestAnimationFrame(init)); // eslint-disable-line
}

window.render();

So later in my React components, I can use window.render()

@gijo-varghese
Copy link
Author

gijo-varghese commented Dec 2, 2018

@zouhir can you pls take a look when you're free?

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