Last active
April 17, 2020 09:08
-
-
Save likidu/f174a9b99e5e7d8e4622e0eb2f6086fc to your computer and use it in GitHub Desktop.
Use Preact with Typescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mounted = useRef(); | |
useEffect(() => { | |
if (!mounted.current) { | |
mounted.current = true; | |
} else { | |
// do componentDidUpate logic | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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