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

Just get "Connected, listening for Preact operations" #299

Closed
carderne opened this issue May 19, 2021 · 2 comments · Fixed by #303
Closed

Just get "Connected, listening for Preact operations" #299

carderne opened this issue May 19, 2021 · 2 comments · Fixed by #303

Comments

@carderne
Copy link

Using the sample code from this comment, running on light-server localhost.

<!DOCTYPE html>
<html>
  <body>  
    <div id="app"></div>
    <script type="module">
      import "https://cdn.skypack.dev/preact/debug";

      import { h, Component, render } from "https://cdn.skypack.dev/preact";
      import htm from "https://cdn.skypack.dev/htm";

      const html = htm.bind(h);

      const app = html`<h1>Hello World!</h1>`;
      render(app, document.getElementById("app"));
    </script>
  </body>
</html>

In both Chrome and Firefox (with uBlock disabled), I get the following message:

Connected, listening for Preact operations...
If this message doesn't go away Preact started rendering before devtools was initialized. You can fix this by adding the preact/debug or preact/devtools import at the top of your entry file.

What am I doing wrong?

@marvinhagemeister
Copy link
Member

Thanks for filing a bug report. By default the devtools will filter out anything that isn't a component. In the snippet above we only render DOM nodes. The devtools doesn't receive any messages because they've been filtered out, so it assumes that nothing was sent.

Adding a component somewhere makes it show up in devtools:

<!DOCTYPE html>
<html>
  <body>
    <div id="app"></div>
    <script type="module">
      import "https://cdn.skypack.dev/preact/debug";

      import { h, Component, render } from "https://cdn.skypack.dev/preact";
      import htm from "https://cdn.skypack.dev/htm";

      const html = htm.bind(h);

-      const app = html`<h1>Hello World!</h1>`;
+      const App = () => html`<h1>Hello World!</h1>`;
-      render(app, document.getElementById("app"));
+      render(html`<${App} />`, document.getElementById("app"));
    </script>
  </body>
</html>

I'm leaving this open as we should be able to print a better message there. Something that hints to the user that the active filters leads to no nodes being shown.

@carderne
Copy link
Author

Thanks for the clarification! What I'm actually trying to do is use Preact with microbundle and I somehow wasn't including "preact/debug" in the correct way.

I've now done it as follows:

// microbundle entry point
export * from "preact/debug";
export * from "preact";
export * from "htm/preact";
...
// my app's entry point
import { html, render } from "./preact-bundle.js";
...

And it's working fine.

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

Successfully merging a pull request may close this issue.

2 participants