-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Hooks broken in pure browser aka "no build tools route" #4477
Comments
Context here #2564 (comment) - are you leveraging an import map as mentioned in your link? Hmm, this might be an issue in glitch 😅 but yes import-maps should work as used by fresh, alternatively you can use the knowledge of the aforementioned link |
Oh.... You aren't using the hook in a component... That can't work 😅 https://glitch.com/edit/#!/intermediate-wide-watch?path=index.html%3A19%3A26 <script type="importmap">
{
"imports": {
"preact": "https://esm.sh/[email protected]",
"preact/": "https://esm.sh/[email protected]/",
"@preact/signals": "https://esm.sh/@preact/[email protected]?external=preact",
"htm/preact": "https://esm.sh/[email protected]/preact?external=preact"
}
}
</script>
<p id="console"></p>
<script type="module">
window.addEventListener("error", (err) => {
document.querySelector("#console").innerHTML = [
err.filename,
err.lineno,
err.colno,
err.message,
].join(": ");
});
import { render } from 'preact';
import { html } from 'htm/preact';
import { useState } from 'preact/hooks';
export function App() {
const [state, setState] = useState('world')
return html`
<h1>Hello, ${state}!</h1>
`;
}
render(html`<${App} />`, document.body);
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
preact/hooks.useState (or any other hook) broken if used as is
To Reproduce
https://periwinkle-tabby-lasagna.glitch.me
https://glitch.com/edit/#!/periwinkle-tabby-lasagna
Steps to reproduce the behavior:
Firefox: Ctrl+Shift+K
Chrome-based: Ctrl+Shift+J
Firefox
Expected behavior
No error, since this hooks mentioned in https://preactjs.com/guide/v10/no-build-workflows/#preact-with-hooks-signals-and-htm
No-Build Workflows -> Recipes and Common Patterns -> Preact with Hooks, Signals, and HTM
The text was updated successfully, but these errors were encountered: