-
-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
78 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"usehooks-ts": minor | ||
--- | ||
|
||
Added debounce option to both `useScreen` and `useWindowSize` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { useScreen } from './useScreen' | ||
|
||
export default function Component() { | ||
const { width = 0, height = 0 } = useScreen() | ||
const screen = useScreen() | ||
|
||
return ( | ||
<div> | ||
The current window dimensions are:{' '} | ||
<code>{JSON.stringify({ width, height })}</code> | ||
<code>{JSON.stringify(screen, null, 2)}</code> | ||
</div> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
Easily retrieve `window.screen` object with this Hook React which also works onResize. | ||
|
||
**Note**: If you use this hook in an SSR context, set the `initializeWithValue` option to `false`, it will initialize with `undefined`. | ||
### Parameters | ||
|
||
- `initializeWithValue?: boolean`: If you use this hook in an SSR context, set it to `false`, it will initialize with `undefined` (default `true`). | ||
- `debounceDelay?: number`: The delay in milliseconds before the callback is invoked (disabled by default for retro-compatibility). |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
Easily retrieve window dimensions with this React Hook which also works onResize. | ||
|
||
**Note**: If you use this hook in an SSR context, set the `initializeWithValue` option to `false`. | ||
### Parameters | ||
|
||
- `initializeWithValue?: boolean`: If you use this hook in an SSR context, set it to `false` (default `true`) | ||
- `debounceDelay?: number`: The delay in milliseconds before the callback is invoked (disabled by default for retro-compatibility). |
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
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