Simplified 3kB alternative to React with the same modern API.

Preact update state on resize event
22 Aug, 2024
You can create a Preact component that rerenders every time the window is resized by using window.addEventListener('resize'). The general approach involves setting up an event listener in a useEffect...

Preact: Add delay to updating a string
22 Aug, 2024
To add a delay to updating a string based on state in Preact, you can use the useEffect hook in combination with setTimeout. This allows you to delay the state update by a certain amount of time...

Run after "set" in Preact
10 Aug, 2024
When using useState in Preact (or React), the setState function doesn't accept a callback as a second parameter, unlike in some other libraries. Instead, the proper way to execute code after a state...

Using addEventListener in Preact
12 Jun, 2024
This example demonstrates how to add and properly clean up event listeners in a Preact functional component using the useEffect hook. A button element is referenced using useRef, and event listeners...

Install Preact
12 Jun, 2022
Installing Preact two ways shown. At first the official way did not work for me. I had to fix permissions for the global node modules, official solution. Then the alternative way worked, and after...