You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/index.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ layout: home
3
3
4
4
hero:
5
5
name: 'react-simplikit'
6
-
text: 'React utility library family'
6
+
text: 'Lightweight and powerful React utility library'
7
7
image:
8
8
src: /images/symbol.svg
9
9
alt: react-simplikit
@@ -16,10 +16,10 @@ hero:
16
16
link: /core/intro
17
17
18
18
features:
19
-
- title: '@react-simplikit/mobile'
20
-
details: Mobile-optimized hooks for web views and hybrid apps. Handle keyboard, viewport, scroll issues.
21
-
link: /mobile/intro
22
-
- title: react-simplikit
23
-
details: Core utilities, hooks, and components for React applications. Zero dependencies.
24
-
link: /core/intro
19
+
- title: 'Zero dependencies'
20
+
details: No external libraries are needed, making your project lightweight, faster, and easier to maintain. Effortlessly reduce bundle size and improve performance.
21
+
- title: 100% Test Coverage
22
+
details: Every function and branch is rigorously tested, ensuring robust and reliable code for any use case.
23
+
- title: Comprehensive Documentation
24
+
details: Each feature includes clear JSDoc comments, beginner-friendly guides, and practical examples. Start quickly with detailed and easy-to-follow instructions.
A React hook that locks body scroll when mounted and automatically unlocks when unmounted. This is particularly useful for modals, drawers, and other overlay components that should prevent background scrolling.
4
-
5
3
## Interface
6
4
7
5
```ts
@@ -10,50 +8,20 @@ function useBodyScrollLock(): void;
When you have multiple overlapping modals, use a single lock at the parent level instead of applying the lock to each modal individually.
33
-
34
-
```tsx
35
-
// Multiple modals - single lock pattern
36
-
function BodyScrollLock() {
37
-
useBodyScrollLock();
38
-
returnnull;
39
-
}
40
-
41
-
function App() {
42
-
const hasModal =showModal1||showModal2;
23
+
````
43
24
44
-
return (
45
-
<>
46
-
{hasModal&& <BodyScrollLock />}
47
-
{showModal1&& <Modal1 />}
48
-
{showModal2&& <Modal2 />}
49
-
</>
50
-
);
51
-
}
52
25
```
53
26
54
-
## Notes
55
-
56
-
-**SSR Safety**: This hook uses `useEffect`, which only runs on the client side, making it safe for server-side rendering (SSR).
57
-
-**Automatic Cleanup**: The scroll lock is automatically removed when the component unmounts, ensuring proper cleanup.
58
-
-**Multiple Modals**: For scenarios with multiple overlapping modals, implement a single lock at the parent level rather than applying locks to each modal individually. This prevents conflicts and ensures consistent behavior.
59
-
-**Browser Support**: Works in all modern browsers that support the underlying CSS modifications applied by the `enableBodyScrollLock` and `disableBodyScrollLock` utilities.
React hook to access Network Information API. Provides raw network connection data including connection type, quality, speed, and user preferences. Returns undefined for all properties if the API is not supported (e.g., Safari, Firefox).
4
-
5
3
## Interface
6
4
7
5
```ts
@@ -10,99 +8,42 @@ function useNetworkStatus(): NetworkStatus;
10
8
11
9
### Parameters
12
10
13
-
This hook takes no parameters.
14
-
15
11
### Return Value
16
12
17
13
<Interface
18
-
name=""
19
-
type="NetworkStatus"
20
-
description="object with network connection data."
Monitors when the user switches tabs or minimizes the browser using the Page Visibility API. This is useful for pausing/resuming animations, videos, or background tasks to improve performance and user experience.
6
-
7
3
## Interface
8
4
9
5
```ts
@@ -12,36 +8,26 @@ function usePageVisibility(): PageVisibility;
12
8
13
9
### Parameters
14
10
15
-
This hook takes no parameters.
16
-
17
11
### Return Value
18
12
19
13
<Interface
20
-
name=""
21
-
type="PageVisibility"
22
-
description="object with page visibility state."
23
-
:nested="[
24
-
{
25
-
name: 'isVisible',
26
-
type: 'boolean',
27
-
required: false,
28
-
description: '<code>true</code> if the page is currently visible to the user',
29
-
},
30
-
{
31
-
name: 'visibilityState',
32
-
type: \"'visible' | 'hidden'\",
33
-
required: false,
34
-
description: 'Current visibility state of the page',
35
-
},
36
-
]"
14
+
name=""
15
+
type="PageVisibility"
16
+
description="visibility information"
17
+
:nested="[
18
+
{
19
+
name: '',
20
+
type: 'isVisible',
21
+
required: false,
22
+
description:
23
+
'True if page is currently visible to the user - <code>visibilityState</code> - Current visibility state<br /> : \'visible\' | \'hidden\'.',
24
+
},
25
+
]"
37
26
/>
38
27
39
-
## Examples
40
-
41
-
### Video Player Control
42
-
43
-
Automatically pause video playback when the user switches to another tab:
-**SSR Safety**: During server-side rendering, this hook returns `{ isVisible: true, visibilityState: 'visible' }` as a safe default since the Page Visibility API is not available on the server.
85
-
-**Browser Support**: The Page Visibility API is supported in all modern browsers. See [MDN Browser Compatibility](https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API#browser_compatibility) for details.
86
-
-**Performance**: The hook uses the native `visibilitychange` event, which is highly optimized and has minimal performance impact.
87
-
-**Visibility States**: The hook excludes the deprecated `'prerender'` state and only returns `'visible'` or `'hidden'`.
0 commit comments