Skip to content

Commit 0658786

Browse files
committed
doc: update jsdoc
1 parent 173739c commit 0658786

13 files changed

Lines changed: 41 additions & 26 deletions

File tree

src/components/ForMemoized.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { For } from "./For";
33
//#IGNORE
44
/**
55
* **`ForMemoized`**: Memoized version of _For_ component.
6-
* {@link For} is wrapped with `React.memo`, preventing re-renders when his props have
7-
* not changed. Prefer this over {@link For} in performance-sensitive
6+
* [For] is wrapped with `React.memo`, preventing re-renders when his props have not changed.
7+
* Prefer this over [For](https://react-tools.ndria.dev/components/For) in performance-sensitive
88
* trees where the parent re-renders frequently.
99
*
1010
* @see [📖 Documentation](https://react-tools.ndria.dev/components/ForMemoized)

src/components/Show.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ function Show<T>({ when, fallback, children, mode = "unmount" }: ShowProps<T>) {
106106
}
107107

108108
if (!when) {
109-
return fallback ? <>{fallback}</> : null;
109+
return fallback ?? null;
110110
}
111-
return <>{children}</>;
111+
return children;
112112
}
113113

114114
export { Show };

src/components/ShowMemoized.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { Show } from "./Show";
55

66
/**
77
* **`ShowMemoized`**: Memoized version of _Show_ component.
8-
* {@link Show} is wrapped with `React.memo`, preventing re-renders when his props have
9-
* not changed. Prefer this over {@link Show} in performance-sensitive
8+
* [Show] is wrapped with `React.memo`, preventing re-renders when his props have not changed.
9+
* Prefer this over [Show](https://react-tools.ndria.dev/components/Show) in performance-sensitive
1010
* trees where the parent re-renders frequently.
1111
*
1212
* @see [📖 Documentation](https://react-tools.ndria.dev/components/ShowMemoized)

src/components/SwitchCaseMemoized.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { Switch } from "./_Switch";
66

77
/**
88
* **`SwitchCaseMemoized`**: Memoized version of _SwitchCase_ component.
9-
* Both {@link Switch} and {@link Case}
10-
* are wrapped with `React.memo`, preventing re-renders when their props have
11-
* not changed. Prefer this over {@link SwitchCase} in performance-sensitive
12-
* trees where the parent re-renders frequently.
9+
* Both [Switch] and [Case] are wrapped with `React.memo`, preventing re-renders
10+
* when their props have not changed.
11+
* Prefer this over [SwitchCase](https://react-tools.ndria.dev/components/SwitchCase)
12+
* in performance-sensitive trees where the parent re-renders frequently.
1313
*
1414
* @see [📖 Documentation](https://react-tools.ndria.dev/components/SwitchCaseMemoized)
1515
*/

src/components/_Case.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { CaseProps } from "../models"
2+
import { Show } from "./Show";
23

34
/**
45
* **`Case`**: Component used inside _SwitchCase_ component to represent a case construct.
6+
*
57
* @see [📖 Documentation](https://react-tools.ndria.dev/components/SwitchCase)
68
* @param {CaseProps} props - {@link CaseProps}
79
* @returns {JSX.Element|null} element
810
*/
9-
export const Case = ({ children, when }: CaseProps) => {
10-
return !when
11-
? null
12-
: <>{children}</>
13-
}
11+
export const Case = ({ children, when }: CaseProps) => (
12+
<Show when={when} mode="unmount">
13+
{children}
14+
</Show>
15+
)

src/components/_Switch.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ import { SwitchProps } from "../models";
88
* @returns {JSX.Element|null} element
99
*/
1010
export const Switch = ({ children, fallback }: SwitchProps) => {
11-
const child = Children.toArray(children).find(el => isValidElement(el) && el.props && el.props.when)
12-
return child
13-
? <>{child}</>
14-
: fallback !== undefined
15-
? <> {fallback}</>
16-
: null;
11+
const activeChild = Children.toArray(children).find(
12+
(el) => isValidElement(el) && el.props.when === true
13+
);
14+
15+
if (!activeChild) {
16+
return fallback ?? null;
17+
}
18+
19+
return activeChild;
1720
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Memoized implementation of _For_ component.
22

3-
Please visit [For component](#/components/For) example to see how it works.
3+
Please visit [For component](https://react-tools.ndria.dev/components/For) example to see how it works.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Memoized implementation of _Show_ component.
22

3-
Please visit [Show component](#/components/Show) example to see how it works.
3+
Please visit [Show component](https://react-tools.ndria.dev/components/Show) example to see how it works.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Memoized implementation of _SwitchCase_ component.
22

3-
Please visit [SwitchCase component](#/components/SwitchCase) example to see how it works.
3+
Please visit [SwitchCase component](https://react-tools.ndria.dev/components/SwitchCase) example to see how it works.

src/hooks/api-dom/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ export { usePromise } from './usePromise';
4545
export { useParallelPromises } from './useParallelPromises';
4646
export { useFetch } from './useFetch';
4747
export { useLock } from './useLock';
48-
export { useBroadcastChannel } from './useBroadcastChannel';
48+
export { useBroadcastChannel } from './useBroadcastChannel';
49+
export { use } from './use';

0 commit comments

Comments
 (0)