Closed danilovmy closed 11 months ago
@danilovmy is this code inside an island?
page:
// index.html
import { signal } from "@preact/signals";
import Hello from "../islands/hello.tsx";
import Layout from "../components/layout.tsx"
const username = signal('');
export default function Home(props) {
return (
<Layout>
<Hello username={username} class="container"/>
</Layout>
);
}
island:
import UsernameForm from "../components/usernameform.tsx";
function changeUsername(event) {
event.preventDefault();
alert('hello');
};
export default function Hello({username}) {
return (
<div class="p-4 mx-auto max-w-screen-md">
<UsernameForm username={username} onclick={changeUsername} />
</div>
);
};
component
export default function UsernameForm({username, onclick}) {
return (
<form>
<input type="text" class="" name="username" value={ username.value || 'Anonym' }/>
<button class="bg-grey-light border rounded p-4 shadow-md" onclick={onclick}>Log in</button>
</form>
);
};
We can throw away Layout, or we can move code from component to island, don't matter. The counter on the fresh homepage not works too. IOs 12.5.5, Safary or Chrome. I check it, for example, with VueJs3: simply counter on the page works.
If it helps: in debug mode before fresh-app starts i see the error:
SyntaxError: Unexpected token ‘?’
promiseReactionJob
I remember, on Fresh 1.4 it probably all, ok, but i am not shure. Sorry.
Looks like it stumbles on some newer JS features. With the upcoming build.target
option you can set esbuild's target option to downtranspile code to the required browser target. It will be released as part of the next Fresh version. See https://github.com/denoland/fresh/pull/1837
Not works:
Works: