Skip to content

Commit 9687694

Browse files
committed
docs: add react hooks bundle size
1 parent ddbfaf8 commit 9687694

6 files changed

Lines changed: 35 additions & 10 deletions

File tree

.export-size-svg.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,10 @@ export default defineConfig({
4747
code: "export { reactiveMap } from './src/collections/reactiveMap.ts';export { reactiveSet } from './src/collections/reactiveSet.ts';export { reactiveArray } from './src/collections/reactiveArray.ts'",
4848
externals: ["../batch", "../readable", "../utils"],
4949
},
50+
{
51+
title: "React Hooks",
52+
code: "export * from './src/react/index.ts'",
53+
externals: ["@embra/reactivity", "react"],
54+
},
5055
],
5156
});

src/react/useCombine.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {
22
combine,
3+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4+
type Readable,
35
type Config,
46
type MapReadablesToValues,
57
type OwnedReadable,
@@ -39,7 +41,7 @@ export interface UseCombine {
3941
* In other words, no extra care is needed to use this in React components. All args will be updated properly.
4042
*
4143
* @example
42-
* ```jsx
44+
* ```tsx
4345
* import { useCombine, useValue } from "@embra/reactivity/react";
4446
*
4547
* function App({ width$, height$ }) {

src/react/useCombined.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { type Config, type MapReadablesToValues, type ReadableLike } from "@embra/reactivity";
1+
import {
2+
type Config,
3+
type MapReadablesToValues,
4+
type ReadableLike,
5+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
6+
type Readable,
7+
} from "@embra/reactivity";
28

39
import { useCombine } from "./useCombine";
410
import { useValue } from "./useValue";
@@ -31,7 +37,7 @@ export interface UseCombined {
3137
* In other words, no extra care is needed to use this in React components. All args will be updated properly.
3238
*
3339
* @example
34-
* ```jsx
40+
* ```tsx
3541
* import { useCombined } from "@embra/reactivity/react";
3642
*
3743
* function App({ width$, height$ }) {

src/react/useDerive.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import {
22
derive,
33
strictEqual,
4+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
5+
type Readable,
46
type Config,
57
type OwnedReadable,
68
type ReadableLike,
@@ -58,7 +60,7 @@ export interface UseDerive {
5860
* In other words, no extra care is needed to use this in React components. All args will be updated properly.
5961
*
6062
* @example
61-
* ```jsx
63+
* ```tsx
6264
* import { useDerive, useValue } from "@embra/reactivity/react";
6365
*
6466
* function App({ position3d$ }) {

src/react/useDerived.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { type Config, type ReadableLike } from "@embra/reactivity";
1+
import {
2+
type Config,
3+
type ReadableLike,
4+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
5+
type Readable,
6+
} from "@embra/reactivity";
27

38
import { useDerive } from "./useDerive";
49
import { useValue } from "./useValue";
@@ -37,7 +42,7 @@ export interface UseDerived {
3742
* In other words, no extra care is needed to use this in React components. All args will be updated properly.
3843
*
3944
* @example
40-
* ```jsx
45+
* ```tsx
4146
* import { useDerived } from "@embra/reactivity/react";
4247
*
4348
* function App({ position3d$ }) {

src/react/useValue.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2-
import { type Readable, type ReadableLike, type Unwrap, getReadable } from "@embra/reactivity";
1+
import {
2+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3+
type Readable,
4+
type ReadableLike,
5+
type Unwrap,
6+
getReadable,
7+
} from "@embra/reactivity";
38
import { useDebugValue, useMemo, useSyncExternalStore } from "react";
49

5-
interface UseValue {
10+
export interface UseValue {
611
/**
712
* Accepts a {@link ReadableLike} and returns the latest value.
813
* It only triggers re-rendering when new value emitted from $ (base on {@link Readable.$version} instead of React's `Object.is` comparison).
@@ -38,7 +43,7 @@ const defaultArgs = [returnsNoop, returnsNoop as () => any] as const;
3843
* @returns the value of the {@link ReadableLike}, or $ itself if $ is not a {@link ReadableLike}
3944
*
4045
* @example
41-
* ```jsx
46+
* ```tsx
4247
* import { useValue } from "@embra/reactivity/react";
4348
*
4449
* function App({ count$ }) {

0 commit comments

Comments
 (0)