Skip to content

Commit ff59e5a

Browse files
committed
Update useDefault description
1 parent 1dccb2c commit ff59e5a

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

usehooks.com/src/content/hooks/useDefault.mdx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ import HookDescription from "../../components/HookDescription.astro";
1313
import StaticCodeContainer from "../../components/StaticCodeContainer.astro";
1414

1515
<HookDescription name={frontmatter.name}>
16-
The useDefault hook is useful for managing state in functional components with
17-
default values. The hook then checks if the "state" is undefined or null. If
18-
it is, it returns an array containing the "defaultValue" and the "setState"
19-
function, allowing the component to set a default value and update the state
20-
accordingly. On the other hand, if the "state" is defined, it returns an array
21-
with the current "state" value and the "setState" function, enabling normal
22-
state management.
16+
The `useDefault` hook behaves similar to `useState` but with one difference – if the state of the hook is `undefined` or `null`, `useDefault` will default the state to a provided default value.
2317
</HookDescription>
2418

2519
<div class="reference">
@@ -28,7 +22,7 @@ import StaticCodeContainer from "../../components/StaticCodeContainer.astro";
2822
<div class="table-container">
2923
| Name | Type | Description |
3024
| ------------ | -------- | ----------- |
31-
| initialValue | any | This is the initial state value provided when calling `useDefault`. |
25+
| initialValue | any | The initial value of the state returned from `useDefault` |
3226
| defaultValue | any | The default value to be used if the state is `undefined` or `null`. |
3327
</div>
3428

0 commit comments

Comments
 (0)