@geee-be/react-utils 1.1.8 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @geee-be/react-utils
2
2
 
3
+ ## 1.1.10
4
+
5
+ ### Patch Changes
6
+
7
+ - 3ad787e: feat: add Monitor
8
+
9
+ ## 1.1.9
10
+
11
+ ### Patch Changes
12
+
13
+ - 48e0d4e: fix negated logic in ClientOnly
14
+
3
15
  ## 1.1.8
4
16
 
5
17
  ### Patch Changes
@@ -3,7 +3,7 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useIsClient } from '../hooks';
4
4
  export const ClientOnly = ({ children, serverFallback }) => {
5
5
  const isClient = useIsClient();
6
- if (isClient)
6
+ if (!isClient)
7
7
  return _jsx(_Fragment, { children: serverFallback });
8
8
  return _jsx(_Fragment, { children: children });
9
9
  };
@@ -1,3 +1,4 @@
1
1
  export { ClientOnly } from './client-only.js';
2
+ export { Monitor } from './monitor.js';
2
3
  export * from './ripple.js';
3
4
  export * from './sub-component.js';
@@ -0,0 +1,13 @@
1
+ 'use client';
2
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
+ import { useRenderCount } from '@uidotdev/usehooks';
4
+ import { useEffect } from 'react';
5
+ export const Monitor = ({ children, label }) => {
6
+ useEffect(() => {
7
+ console.log(label, 'mounted');
8
+ return () => console.log(label, 'unmounted');
9
+ }, [label]);
10
+ const count = useRenderCount();
11
+ console.log(label, 'rendered', count);
12
+ return _jsx(_Fragment, { children: children });
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geee-be/react-utils",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -28,6 +28,9 @@
28
28
  "react": ">=18.0.0",
29
29
  "react-dom": ">=18.0.0"
30
30
  },
31
+ "dependencies": {
32
+ "@uidotdev/usehooks": "^2.4.1"
33
+ },
31
34
  "scripts": {
32
35
  "prebuild": "rimraf dist/*",
33
36
  "build": "tsc",
@@ -9,6 +9,6 @@ interface Props extends PropsWithChildren {
9
9
 
10
10
  export const ClientOnly: FC<Props> = ({ children, serverFallback }) => {
11
11
  const isClient = useIsClient();
12
- if (isClient) return <>{serverFallback}</>;
12
+ if (!isClient) return <>{serverFallback}</>;
13
13
  return <>{children}</>;
14
14
  };
@@ -1,3 +1,4 @@
1
1
  export { ClientOnly } from './client-only.js';
2
+ export { Monitor } from './monitor.js';
2
3
  export * from './ripple.js';
3
4
  export * from './sub-component.js';
@@ -0,0 +1,18 @@
1
+ 'use client';
2
+
3
+ import { useRenderCount } from '@uidotdev/usehooks';
4
+ import { useEffect, type FC, type PropsWithChildren } from 'react';
5
+
6
+ type Props = PropsWithChildren<{ label: string }>;
7
+
8
+ export const Monitor: FC<Props> = ({ children, label }) => {
9
+ useEffect(() => {
10
+ console.log(label, 'mounted');
11
+ return () => console.log(label, 'unmounted');
12
+ }, [label]);
13
+
14
+ const count = useRenderCount();
15
+ console.log(label, 'rendered', count);
16
+
17
+ return <>{children}</>;
18
+ };