I have a basic application in Vite.
Why can't I type in the input field?
import React from "react";
import { signal, computed } from "@preact/signals-react";
const name = signal<string>("");
const disabled = computed<boolean>(() => name.value.trim() === "");
const Welcome = () => {
return (
<div>
<input value={name.value} onInput={e => (name.value = e.currentTarget.value)} />
<p>Name: {name.value}</p>
<p>Disabled: {disabled.value ? "true" : "false"}</p>
</div>
);
};
export default Welcome;
Please add the following in vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react({
babel: {
plugins: [['module:@preact/signals-react-transform']],
},
}),
],
});
Refer - https://www.npmjs.com/package/@preact/signals-react
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With