Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion docs/use-callback-const.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# `useCallbackConst`

Documentation coming soon...
Creates a callback with a constant value over the lifecycle of a component.

## Example

```tsx
const immutableCallback = useCallbackConst(() => {
console.log(
`I don't have any local state dependencies
and I won't trigger unncessary re-renders.`
);
});

<button onClick={immutableCallback}>Click me to increment: {count}</button>
```
26 changes: 25 additions & 1 deletion docs/use-callback-ref.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# `useCallbackRef`

Documentation coming soon...
Converts a callback to a ref to avoid triggering re-renders when passed as a
prop or avoid re-executing effects when passed as a dependency.

Returns a new callback with a constant value over the lifecycle of a component.

## Example

```tsx
const [state, setState] = useState(0);

const logState = useCallbackRef(() => {
console.log('state:', state);
});

useEffect(() => {
logState();
// => "state: 1"
// => "state: 2"
// => "state: 3"
// => "state: 4"
// => ...
}, [state]);

<button onClick={() => setState((curr) => curr + 1)}>Click me to increment: {count}</button>
```
10 changes: 9 additions & 1 deletion docs/use-value-ref.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# `useValueRef`

Documentation coming soon...
Converts a given value to a ref to avoid triggering re-renders when passed as a
prop or avoid re-executing effects when passed as a dependency.

Returns a ref object with a constant value over the lifecycle of a component.

## Example

Example coming soon...