@graphcommerce/next-ui 11.0.0-canary.46 → 11.0.0-canary.48
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 +28 -0
- package/Intl/ListFormat/ListFormat.tsx +16 -4
- package/LazyHydrate/LazyHydrate.tsx +20 -7
- package/OverlayOrPopperChip/PopperPanel.test.tsx +46 -0
- package/OverlayOrPopperChip/PopperPanel.tsx +18 -13
- package/Page/CssAndFramerMotionProvider.tsx +21 -1
- package/Row/RowLinks/RowLinks.tsx +2 -0
- package/index.test.ts +20 -0
- package/index.ts +1 -0
- package/package.json +8 -8
- package/utils/cookie.ts +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 11.0.0-canary.48
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2699](https://github.com/graphcommerce-org/graphcommerce/pull/2699) [`f28586b`](https://github.com/graphcommerce-org/graphcommerce/commit/f28586b061f48cce3f3a70f7ec2c57f13868f8e1) - The packages export the modules that shops import from the package root: the types of `RichText`, `GetAddressesDocument`, `isSameAddress`, `isCartAddressACustomerAddress`, `AvailableShippingMethodFragment`, `AccountAddressFragment`, `CreateCustomerAddressDocument`, `UpdateCustomerAddressDocument`, `ValidatedPasswordElement`, `useCustomizableOptionPrice`, `UseAddProductsToCartActionFragment`, `useProductFiltersProSearchInput`, `useSearchPageAndParam`, `AddWishlistItemToCartProps` and `safeJsonLdReplacer`. ([@bramvanderholst](https://github.com/bramvanderholst))
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#2679](https://github.com/graphcommerce-org/graphcommerce/pull/2679) [`4d0bb18`](https://github.com/graphcommerce-org/graphcommerce/commit/4d0bb1822241d919e2f57495f644afbd4ea3baf2) - Reduce Total Blocking Time by removing synchronous re-renders right after hydration and splitting up startup work:
|
|
12
|
+
|
|
13
|
+
- `usePrivateQuery` no longer uses `useIsSSR()`. Its `useSyncExternalStore` server/client mismatch forced a synchronous re-render of the whole page after hydration, even for guests. Without a private context the mask stays on, which is inert because it only hides content while the `private-query` CSS flag is set.
|
|
14
|
+
- `useCookie(name)` subscribes to a single cookie via `useSyncExternalStore` (server snapshot `null`), so it only re-renders after hydration when that cookie is actually set.
|
|
15
|
+
- `usePrivateQueryContext` (magento-customer plugin) subscribes to the derived `loggedIn` boolean on the Apollo cache instead of the full `CustomerToken` query result, so the page doesn't re-render when the query result object changes but `loggedIn` doesn't.
|
|
16
|
+
- `CssAndFramerMotionProvider` loads framer-motion features after hydration and applies them in `startTransition`, so the re-render of all `m` components is time-sliced and the features stay out of the startup bundle.
|
|
17
|
+
- Examples: `ThemeProvider` uses `noSsr`, avoiding MUI's color scheme provider re-rendering every styled component after hydration (`colorSchemeSelector: 'class'` already handles the color scheme in CSS before paint).
|
|
18
|
+
- Examples: added `patch-package` patches for `next@16.2.6` (Pages Router hydrates inside `startTransition`, like the App Router; the route loader yields between `_app` and page instantiation) and `react-hook-form@7.67.0` (only set `formState.isReady` when it is subscribed to; the unconditional update re-rendered every form synchronously after mount).
|
|
19
|
+
- `ListFormat` renders a single item directly instead of creating an `Intl.ListFormat`, which loads its locale data on first use. The store switcher in the header rendered one item on every page; this cut ~12–18% of TBT at 4× CPU throttling.
|
|
20
|
+
- `useElementScroll` no longer measures `scrollWidth` synchronously in its layout effect, which forced a style recalc and layout of the whole page during the hydration commit. It measures in framer-motion's read step instead; the ResizeObserver also delivers an initial observation.
|
|
21
|
+
- `framer-utils` uses framer-motion's `frame` instead of `framesync`, and `framer-scroller` loads `popmotion` on demand (only needed after user interaction). Together ~53 KB raw of JS out of the startup bundle. ([@paales](https://github.com/paales))
|
|
22
|
+
|
|
23
|
+
- [#2683](https://github.com/graphcommerce-org/graphcommerce/pull/2683) [`24612c2`](https://github.com/graphcommerce-org/graphcommerce/commit/24612c27c98dda60d7281fff85eb9437024a05f8) - `LazyHydrate` keeps the server-rendered HTML when its parent renders again before hydration. With a `height`, it renders its content when the browser is idle after a client-side navigation. Find-in-page finds the content below the fold in both cases. ([@paales](https://github.com/paales))
|
|
24
|
+
|
|
25
|
+
- [#2698](https://github.com/graphcommerce-org/graphcommerce/pull/2698) [`1f56a16`](https://github.com/graphcommerce-org/graphcommerce/commit/1f56a160567101a996445d76ee7b06f3b0e1702b) - `PopperPanel` passes `popperProps` to the `Popper` and merges `popperProps.sx` with its own `sx`. It passed `popperProps` to `PopperPanelActions`, so the prop had no effect. ([@bramvanderholst](https://github.com/bramvanderholst))
|
|
26
|
+
|
|
27
|
+
- [#2706](https://github.com/graphcommerce-org/graphcommerce/pull/2706) [`2518b60`](https://github.com/graphcommerce-org/graphcommerce/commit/2518b60f50072683ef556c167b770efc29840de8) - RowLinks items show a visible keyboard focus outline that the scroller does not clip. ([@DivaniNL](https://github.com/DivaniNL))
|
|
28
|
+
|
|
29
|
+
## 11.0.0-canary.47
|
|
30
|
+
|
|
3
31
|
## 11.0.0-canary.46
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
|
@@ -6,12 +6,13 @@ export type ListFormatProps = {
|
|
|
6
6
|
children: React.ReactNode[]
|
|
7
7
|
} & UseIntlListFormatOptions
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
function ListFormatMultiple(props: {
|
|
10
|
+
childArray: React.ReactNode[]
|
|
11
|
+
options: UseIntlListFormatOptions
|
|
12
|
+
}) {
|
|
13
|
+
const { childArray, options } = props
|
|
12
14
|
const formatter = useIntlListFormat(options)
|
|
13
15
|
|
|
14
|
-
const childArray = React.Children.toArray(children)
|
|
15
16
|
const fauxChildren = childArray.map((child, index) => `${index}`) ?? []
|
|
16
17
|
const parts = formatter.formatToParts(fauxChildren)
|
|
17
18
|
|
|
@@ -26,3 +27,14 @@ export function ListFormat(props: ListFormatProps) {
|
|
|
26
27
|
</>
|
|
27
28
|
)
|
|
28
29
|
}
|
|
30
|
+
|
|
31
|
+
/** @public */
|
|
32
|
+
export function ListFormat(props: ListFormatProps) {
|
|
33
|
+
const { children, ...options } = props
|
|
34
|
+
const childArray = React.Children.toArray(children)
|
|
35
|
+
|
|
36
|
+
// A single item needs no list formatting; skip creating an Intl.ListFormat, which loads its locale data on first use.
|
|
37
|
+
if (childArray.length < 2) return <>{childArray}</>
|
|
38
|
+
|
|
39
|
+
return <ListFormatMultiple childArray={childArray} options={options} />
|
|
40
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useIsomorphicLayoutEffect } from '@graphcommerce/framer-utils'
|
|
2
2
|
import type { BoxProps } from '@mui/material'
|
|
3
3
|
import { Box } from '@mui/material'
|
|
4
|
+
import { cancelIdleCallback, requestIdleCallback } from 'next/dist/client/request-idle-callback'
|
|
4
5
|
import type { CSSProperties } from 'react'
|
|
5
6
|
import React, { startTransition, useRef, useState } from 'react'
|
|
6
7
|
|
|
@@ -28,11 +29,15 @@ export type LazyHydrateProps = BoxProps<'div'> & {
|
|
|
28
29
|
* side, because using an IntersectionObserver on an element with no height, will cause all
|
|
29
30
|
* siblings to render at once.
|
|
30
31
|
*
|
|
31
|
-
* By proving a height, we can use the IntersectionObserver on the client as well.
|
|
32
|
+
* By proving a height, we can use the IntersectionObserver on the client as well. The content
|
|
33
|
+
* still renders when the browser is idle, so find-in-page finds it.
|
|
32
34
|
*/
|
|
33
35
|
height?: CSSProperties['height']
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
// React sets innerHTML again when this object changes, which removes the server-rendered HTML
|
|
39
|
+
const keepServerHtml = { __html: '' }
|
|
40
|
+
|
|
36
41
|
/**
|
|
37
42
|
* LazyHydrate can defer the hydration of a component until it becomes visible. OR manually by using
|
|
38
43
|
* the hydrated prop. This can be a way to improve the TBT of a page.
|
|
@@ -48,8 +53,10 @@ export function LazyHydrate(props: LazyHydrateProps) {
|
|
|
48
53
|
// If we are manually hydrating, we watch that value and do not use the IntersectionObserver
|
|
49
54
|
if (isHydrated || !rootRef.current) return undefined
|
|
50
55
|
|
|
56
|
+
const serverRendered = rootRef.current.hasAttribute('data-lazy-hydrate')
|
|
57
|
+
|
|
51
58
|
// If the element wasn't rendered on the server, we hydrate it immediately
|
|
52
|
-
if (!height && !
|
|
59
|
+
if (!height && !serverRendered) {
|
|
53
60
|
setIsHydrated(true)
|
|
54
61
|
return undefined
|
|
55
62
|
}
|
|
@@ -57,17 +64,23 @@ export function LazyHydrate(props: LazyHydrateProps) {
|
|
|
57
64
|
// The user has opted to manually hydrate the component
|
|
58
65
|
if (hydrated !== undefined) return undefined
|
|
59
66
|
|
|
67
|
+
const hydrate = () => startTransition(() => setIsHydrated(true))
|
|
68
|
+
|
|
60
69
|
const observer = new IntersectionObserver(
|
|
61
70
|
([entry]) => {
|
|
62
|
-
if (entry.isIntersecting && entry.intersectionRatio > 0)
|
|
63
|
-
startTransition(() => setIsHydrated(true))
|
|
64
|
-
}
|
|
71
|
+
if (entry.isIntersecting && entry.intersectionRatio > 0) hydrate()
|
|
65
72
|
},
|
|
66
73
|
{ rootMargin: '200px' },
|
|
67
74
|
)
|
|
68
75
|
observer.observe(rootRef.current)
|
|
69
76
|
|
|
70
|
-
|
|
77
|
+
// A client-rendered element stays empty until it renders, so render it when the browser is idle
|
|
78
|
+
const idle = serverRendered ? undefined : requestIdleCallback(hydrate)
|
|
79
|
+
|
|
80
|
+
return () => {
|
|
81
|
+
observer.disconnect()
|
|
82
|
+
if (idle !== undefined) cancelIdleCallback(idle)
|
|
83
|
+
}
|
|
71
84
|
}, [height, hydrated, isHydrated])
|
|
72
85
|
|
|
73
86
|
if (isHydrated) {
|
|
@@ -86,7 +99,7 @@ export function LazyHydrate(props: LazyHydrateProps) {
|
|
|
86
99
|
<Box
|
|
87
100
|
ref={rootRef}
|
|
88
101
|
// eslint-disable-next-line react/no-danger
|
|
89
|
-
dangerouslySetInnerHTML={
|
|
102
|
+
dangerouslySetInnerHTML={keepServerHtml}
|
|
90
103
|
suppressHydrationWarning
|
|
91
104
|
{...elementProps}
|
|
92
105
|
style={{ ...elementProps.style, height }}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
|
|
3
|
+
import type React from 'react'
|
|
4
|
+
import { act } from 'react'
|
|
5
|
+
import { createRoot } from 'react-dom/client'
|
|
6
|
+
import { afterAll, beforeAll, expect, it, vi } from 'vitest'
|
|
7
|
+
import { PopperPanel } from './PopperPanel'
|
|
8
|
+
|
|
9
|
+
vi.mock('./PopperPanelActions', () => ({
|
|
10
|
+
PopperPanelActions: (props: { children: React.ReactNode }) => props.children,
|
|
11
|
+
}))
|
|
12
|
+
|
|
13
|
+
beforeAll(() => {
|
|
14
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
afterAll(() => {
|
|
18
|
+
Reflect.deleteProperty(globalThis, 'IS_REACT_ACT_ENVIRONMENT')
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('passes popperProps to the Popper', () => {
|
|
22
|
+
const anchor = document.createElement('button')
|
|
23
|
+
const container = document.createElement('div')
|
|
24
|
+
document.body.append(anchor, container)
|
|
25
|
+
const root = createRoot(container)
|
|
26
|
+
|
|
27
|
+
act(() =>
|
|
28
|
+
root.render(
|
|
29
|
+
<PopperPanel
|
|
30
|
+
activeEl={anchor}
|
|
31
|
+
title='Filter'
|
|
32
|
+
onApply={() => {}}
|
|
33
|
+
onClose={() => {}}
|
|
34
|
+
popperProps={{ className: 'CustomPopper' }}
|
|
35
|
+
>
|
|
36
|
+
{() => 'Content'}
|
|
37
|
+
</PopperPanel>,
|
|
38
|
+
),
|
|
39
|
+
)
|
|
40
|
+
const popper = container.querySelector('.CustomPopper')
|
|
41
|
+
act(() => root.unmount())
|
|
42
|
+
anchor.remove()
|
|
43
|
+
container.remove()
|
|
44
|
+
|
|
45
|
+
expect(popper).not.toBeNull()
|
|
46
|
+
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PopperProps } from '@mui/material'
|
|
2
2
|
import { ClickAwayListener, Popper } from '@mui/material'
|
|
3
3
|
import { useRef } from 'react'
|
|
4
|
+
import { sxx } from '../utils/sxx'
|
|
4
5
|
import { PopperPanelActions } from './PopperPanelActions'
|
|
5
6
|
import type { PanelProps } from './types'
|
|
6
7
|
import { useHandleClickNotDrag } from './useHandleClickNotDrag'
|
|
@@ -10,7 +11,7 @@ export type PopperPanelProps = PanelProps & {
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export function PopperPanel(props: PopperPanelProps) {
|
|
13
|
-
const { activeEl, children, ...actionsProps } = props
|
|
14
|
+
const { activeEl, children, popperProps, ...actionsProps } = props
|
|
14
15
|
const ref = useRef<HTMLDivElement>(null)
|
|
15
16
|
const movement = useHandleClickNotDrag(ref)
|
|
16
17
|
const handleClickAway = () => {
|
|
@@ -23,21 +24,25 @@ export function PopperPanel(props: PopperPanelProps) {
|
|
|
23
24
|
return (
|
|
24
25
|
<ClickAwayListener onClickAway={handleClickAway}>
|
|
25
26
|
<Popper
|
|
27
|
+
{...popperProps}
|
|
26
28
|
ref={ref}
|
|
27
29
|
open={Boolean(activeEl)}
|
|
28
30
|
anchorEl={activeEl}
|
|
29
|
-
sx={
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
sx={sxx(
|
|
32
|
+
{
|
|
33
|
+
boxShadow: 12,
|
|
34
|
+
borderRadius: 3,
|
|
35
|
+
overflow: 'hidden',
|
|
36
|
+
zIndex: 1,
|
|
37
|
+
bgcolor: 'background.paper',
|
|
38
|
+
display: 'grid',
|
|
39
|
+
gridTemplateRows: 'min-content auto min-content',
|
|
40
|
+
minWidth: 350,
|
|
41
|
+
overflowY: 'auto',
|
|
42
|
+
maxHeight: '500px',
|
|
43
|
+
},
|
|
44
|
+
popperProps?.sx,
|
|
45
|
+
)}
|
|
41
46
|
disablePortal
|
|
42
47
|
modifiers={[
|
|
43
48
|
{ name: 'offset', options: { offset: [0, 10] } },
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import { GlobalStyles } from '@mui/material'
|
|
2
|
+
import type { FeatureBundle } from 'framer-motion'
|
|
2
3
|
import { LazyMotion } from 'framer-motion'
|
|
4
|
+
import { startTransition, useEffect, useState } from 'react'
|
|
3
5
|
import type { EmotionProviderProps } from '../Styles/EmotionProvider'
|
|
4
6
|
import { EmotionProvider } from '../Styles/EmotionProvider'
|
|
5
7
|
|
|
8
|
+
// Until the features are loaded `m` components render as plain elements.
|
|
9
|
+
const noFeatures = {} as FeatureBundle
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Loads framer-motion's features after hydration and applies them in a transition, so the resulting
|
|
13
|
+
* re-render of all `m` components is time-sliced instead of one blocking task, and the features
|
|
14
|
+
* stay out of the startup bundle.
|
|
15
|
+
*/
|
|
16
|
+
function useFramerFeatures() {
|
|
17
|
+
const [features, setFeatures] = useState<FeatureBundle>(noFeatures)
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
import('./framerFeatures')
|
|
20
|
+
.then((m) => startTransition(() => setFeatures(m.default)))
|
|
21
|
+
.catch(console.error)
|
|
22
|
+
}, [])
|
|
23
|
+
return features
|
|
24
|
+
}
|
|
25
|
+
|
|
6
26
|
export type CssAndFramerMotionProviderProps = EmotionProviderProps
|
|
7
27
|
|
|
8
28
|
/**
|
|
@@ -16,7 +36,7 @@ export function CssAndFramerMotionProvider(props: CssAndFramerMotionProviderProp
|
|
|
16
36
|
const { children, emotionCache } = props
|
|
17
37
|
return (
|
|
18
38
|
<EmotionProvider emotionCache={emotionCache}>
|
|
19
|
-
<LazyMotion features={
|
|
39
|
+
<LazyMotion features={useFramerFeatures()} strict>
|
|
20
40
|
{children}
|
|
21
41
|
<GlobalStyles
|
|
22
42
|
styles={{
|
package/index.test.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
import ts from 'typescript'
|
|
3
|
+
|
|
4
|
+
it('exports the modules that a shop imports', () => {
|
|
5
|
+
const root = fileURLToPath(new URL('.', import.meta.url))
|
|
6
|
+
const files = ts.sys
|
|
7
|
+
.readDirectory(root, ['.ts', '.tsx'])
|
|
8
|
+
.filter((file) => !file.includes('/node_modules/') && !/\.test\.tsx?$/.test(file))
|
|
9
|
+
const program = ts.createProgram(files, {
|
|
10
|
+
noEmit: true,
|
|
11
|
+
noResolve: true,
|
|
12
|
+
jsx: ts.JsxEmit.ReactJSX,
|
|
13
|
+
})
|
|
14
|
+
const checker = program.getTypeChecker()
|
|
15
|
+
const index = program.getSourceFile(`${root}index.ts`)
|
|
16
|
+
const moduleSymbol = index && checker.getSymbolAtLocation(index)
|
|
17
|
+
const exported = moduleSymbol ? checker.getExportsOfModule(moduleSymbol).map((s) => s.name) : []
|
|
18
|
+
|
|
19
|
+
expect(exported).toEqual(expect.arrayContaining(['safeJsonLdReplacer']))
|
|
20
|
+
})
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/next-ui",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "11.0.0-canary.
|
|
5
|
+
"version": "11.0.0-canary.48",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"@emotion/react": "^11.14.0",
|
|
44
44
|
"@emotion/server": "^11.11.0",
|
|
45
45
|
"@emotion/styled": "^11.14.1",
|
|
46
|
-
"@graphcommerce/eslint-config-pwa": "^11.0.0-canary.
|
|
47
|
-
"@graphcommerce/framer-next-pages": "^11.0.0-canary.
|
|
48
|
-
"@graphcommerce/framer-scroller": "^11.0.0-canary.
|
|
49
|
-
"@graphcommerce/framer-utils": "^11.0.0-canary.
|
|
50
|
-
"@graphcommerce/image": "^11.0.0-canary.
|
|
51
|
-
"@graphcommerce/prettier-config-pwa": "^11.0.0-canary.
|
|
52
|
-
"@graphcommerce/typescript-config-pwa": "^11.0.0-canary.
|
|
46
|
+
"@graphcommerce/eslint-config-pwa": "^11.0.0-canary.48",
|
|
47
|
+
"@graphcommerce/framer-next-pages": "^11.0.0-canary.48",
|
|
48
|
+
"@graphcommerce/framer-scroller": "^11.0.0-canary.48",
|
|
49
|
+
"@graphcommerce/framer-utils": "^11.0.0-canary.48",
|
|
50
|
+
"@graphcommerce/image": "^11.0.0-canary.48",
|
|
51
|
+
"@graphcommerce/prettier-config-pwa": "^11.0.0-canary.48",
|
|
52
|
+
"@graphcommerce/typescript-config-pwa": "^11.0.0-canary.48",
|
|
53
53
|
"@lingui/core": "^5",
|
|
54
54
|
"@lingui/macro": "^5",
|
|
55
55
|
"@lingui/react": "^5",
|
package/utils/cookie.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { useMotionValueValue } from '@graphcommerce/framer-utils'
|
|
|
2
2
|
import type { SerializeOptions } from 'cookie'
|
|
3
3
|
import { parse, serialize } from 'cookie'
|
|
4
4
|
import { motionValue } from 'framer-motion'
|
|
5
|
+
import { useSyncExternalStore } from 'react'
|
|
5
6
|
import { useIsSSR } from '../hooks'
|
|
6
7
|
|
|
7
8
|
// We need this motionValue to be synced with the actual cookie store.
|
|
@@ -67,7 +68,13 @@ export function useCookie<T extends string>(
|
|
|
67
68
|
else cookie(name, null)
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
// Subscribe to this single cookie; the server snapshot is `null`, so hydration only causes a re-render
|
|
72
|
+
// when this specific cookie is actually set.
|
|
73
|
+
const raw = useSyncExternalStore(
|
|
74
|
+
(onChange) => cookieNotify.on('change', onChange),
|
|
75
|
+
() => (cookie(name) as T | undefined) ?? null,
|
|
76
|
+
() => null,
|
|
77
|
+
)
|
|
78
|
+
const value = raw ?? defaultValue
|
|
72
79
|
return [value, update] as const
|
|
73
80
|
}
|