Skip to content

Instantly share code, notes, and snippets.

@likidu
Last active April 17, 2020 09:08
Show Gist options
  • Save likidu/f174a9b99e5e7d8e4622e0eb2f6086fc to your computer and use it in GitHub Desktop.
Save likidu/f174a9b99e5e7d8e4622e0eb2f6086fc to your computer and use it in GitHub Desktop.
Use Preact with Typescript
const mounted = useRef();
useEffect(() => {
if (!mounted.current) {
mounted.current = true;
} else {
// do componentDidUpate logic
}
});
import { h, render, Component, JSX } from 'preact'
class Foo extends Component {
onInput({currentTarget}: JSX.TargetedEvent<HTMLInputElement, Event>) {
console.log(currentTarget.value)
}
render() {
return <input onInput={this.onInput} />
}
}
render(<Foo />, document.body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment