Skip to content

Conversation

rschristian
Copy link
Member

We're missing a number of compat-only hooks from our docs and per our Algolia stats, a number of user are searching for them. As such, I felt it was worth adding docs even for the hooks that are stubbed out.

While I was at it I noticed we were missing docs for useDebugValue and our useLayoutEffect description was quite light, so I added them too.

Comment on lines +86 to 87
apply: 'build',
async buildStart() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mentioned this in the other PR but looks like it was missed: this.emitFile cannot be used in Vite's dev mode and it'll emit warnings over this. The closest equivalent for us would be adding a middleware likely, as nothing else consumes the result, but in lieu of that, we should limit this to builds.

Comment on lines +555 to +565
Optionally, you can also pass a function as the second argument to `useDebugValue` for use as the "formatter".

```jsx
import { useDebugValue, useState } from 'preact/hooks';

function useCount() {
const [count, setCount] = useState(0);
useDebugValue(count, c => `Count: ${c}`);
return [count, setCount];
}
```
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: the formatter arg is lazy in React, hence why it exists, but our impl is very much not. It immediately calls the formatter upon ever render of the component, regardless of whether devtools are inspecting the element.

Not sure if that was intentional or not.

@rschristian rschristian merged commit 5b2f95e into master Jul 15, 2025
5 checks passed
@rschristian rschristian deleted the docs/hooks branch July 15, 2025 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants