Skip to content

Commit 0f06e75

Browse files
chore: upgrade Zustand
1 parent 2fbf8ac commit 0f06e75

File tree

6 files changed

+50
-36
lines changed

6 files changed

+50
-36
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@
5757
"dependencies": {
5858
"@types/react-reconciler": "^0.28.9",
5959
"@types/webxr": "*",
60-
"its-fine": "^1.2.5",
60+
"its-fine": "^2.0.0",
6161
"react-reconciler": "^0.31.0",
6262
"react-use-measure": "^2.1.1",
6363
"scheduler": "^0.25.0",
6464
"suspend-react": "^0.1.3",
65-
"zustand": "^4.5.2"
65+
"use-sync-external-store": "^1.5.0",
66+
"zustand": "^5.0.6"
6667
},
6768
"peerDependencies": {
6869
"expo-gl": ">=11.4",

src/Canvas.native.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ const CanvasImpl = React.forwardRef<View, CanvasProps>(function Canvas(
5454
// Render to screen
5555
if (canvas && width > 0 && height > 0) {
5656
render(
57-
// @ts-expect-error
5857
<Bridge>
5958
<ErrorBoundary set={setError}>
6059
<React.Suspense fallback={<Block set={setBlock} />}>{children}</React.Suspense>
@@ -110,7 +109,6 @@ const CanvasImpl = React.forwardRef<View, CanvasProps>(function Canvas(
110109
*/
111110
export const Canvas = React.forwardRef<View, CanvasProps>(function CanvasWrapper(props, ref) {
112111
return (
113-
// @ts-expect-error
114112
<FiberProvider>
115113
<CanvasImpl {...props} ref={ref} />
116114
</FiberProvider>

src/Canvas.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ const CanvasImpl = React.forwardRef<HTMLCanvasElement, CanvasProps>(function Can
4949
// Render to screen
5050
if (canvas && width > 0 && height > 0) {
5151
render(
52-
// @ts-expect-error
5352
<Bridge>
5453
<ErrorBoundary set={setError}>
5554
<React.Suspense fallback={<Block set={setBlock} />}>{children}</React.Suspense>
@@ -100,7 +99,6 @@ const CanvasImpl = React.forwardRef<HTMLCanvasElement, CanvasProps>(function Can
10099
*/
101100
export const Canvas = React.forwardRef<HTMLCanvasElement, CanvasProps>(function CanvasWrapper(props, ref) {
102101
return (
103-
// @ts-expect-error
104102
<FiberProvider>
105103
<CanvasImpl {...props} ref={ref} />
106104
</FiberProvider>

src/renderer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as OGL from 'ogl'
22
import * as React from 'react'
33
import { ConcurrentRoot } from 'react-reconciler/constants.js'
4-
import { create } from 'zustand'
4+
import { createWithEqualityFn } from 'zustand/traditional'
55
import { reconciler } from './reconciler'
66
import { OGLContext, useStore, useIsomorphicLayoutEffect } from './hooks'
77
import { RenderProps, Root, RootState, RootStore, Subscription } from './types'
@@ -29,7 +29,7 @@ export function render(
2929
let root = roots.get(target)
3030
if (!root) {
3131
// Create root store
32-
const store = create<RootState>((set, get) => {
32+
const store = createWithEqualityFn<RootState>((set, get) => {
3333
// Create renderer
3434
const renderer =
3535
config.renderer instanceof OGL.Renderer
@@ -230,7 +230,7 @@ function PortalRoot({ children, target, state }: PortalRootProps): React.JSX.Ele
230230
const store = useStore()
231231
const container = React.useMemo(
232232
() =>
233-
create<RootState>((set, get) => ({
233+
createWithEqualityFn<RootState>((set, get) => ({
234234
...store.getState(),
235235
set,
236236
get,

src/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import type * as OGL from 'ogl'
33
import type * as React from 'react'
44
import type {} from 'react/jsx-runtime'
55
import type {} from 'react/jsx-dev-runtime'
6-
import type { UseBoundStore, StoreApi } from 'zustand'
6+
import { createWithEqualityFn, type UseBoundStoreWithEqualityFn } from 'zustand/traditional'
7+
import type { StoreApi } from 'zustand'
78

89
type Mutable<P> = { [K in keyof P]: P[K] | Readonly<P[K]> }
910
type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends Function ? never : K }[keyof P]
@@ -82,7 +83,7 @@ export interface RootState {
8283

8384
export type Act = <T = any>(cb: () => Promise<T>) => Promise<T>
8485

85-
export type RootStore = UseBoundStore<StoreApi<RootState>>
86+
export type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
8687

8788
export interface Root {
8889
render: (element: React.ReactNode) => RootStore

yarn.lock

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,13 +1855,6 @@
18551855
dependencies:
18561856
"@types/react" "*"
18571857

1858-
"@types/react-reconciler@^0.28.0":
1859-
version "0.28.0"
1860-
resolved "https://registry.yarnpkg.com/@types/react-reconciler/-/react-reconciler-0.28.0.tgz#513acbed173140e958c909041ca14eb40412077f"
1861-
integrity sha512-5cjk9ottZAj7eaTsqzPUIlrVbh3hBAO2YaEL1rkjHKB3xNAId7oU8GhzvAX+gfmlfoxTwJnBjPxEHyxkEA1Ffg==
1862-
dependencies:
1863-
"@types/react" "*"
1864-
18651858
"@types/react-reconciler@^0.28.9":
18661859
version "0.28.9"
18671860
resolved "https://registry.yarnpkg.com/@types/react-reconciler/-/react-reconciler-0.28.9.tgz#d24b4864c384e770c83275b3fe73fba00269c83b"
@@ -4400,12 +4393,12 @@ istanbul-reports@^3.1.3:
44004393
html-escaper "^2.0.0"
44014394
istanbul-lib-report "^3.0.0"
44024395

4403-
its-fine@^1.2.5:
4404-
version "1.2.5"
4405-
resolved "https://registry.yarnpkg.com/its-fine/-/its-fine-1.2.5.tgz#5466c287f86a0a73e772c8d8d515626c97195dc9"
4406-
integrity sha512-fXtDA0X0t0eBYAGLVM5YsgJGsJ5jEmqZEPrGbzdf5awjv0xE7nqv3TVnvtUF060Tkes15DbDAKW/I48vsb6SyA==
4396+
its-fine@^2.0.0:
4397+
version "2.0.0"
4398+
resolved "https://registry.yarnpkg.com/its-fine/-/its-fine-2.0.0.tgz#a90b18a3ee4c211a1fb6faac2abcc2b682ce1f21"
4399+
integrity sha512-KLViCmWx94zOvpLwSlsx6yOCeMhZYaxrJV87Po5k/FoZzcPSahvK5qJ7fYhS61sZi5ikmh2S3Hz55A2l3U69ng==
44074400
dependencies:
4408-
"@types/react-reconciler" "^0.28.0"
4401+
"@types/react-reconciler" "^0.28.9"
44094402

44104403
jackspeak@^3.1.2:
44114404
version "3.4.3"
@@ -6893,7 +6886,16 @@ string-length@^4.0.1:
68936886
char-regex "^1.0.2"
68946887
strip-ansi "^6.0.0"
68956888

6896-
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
6889+
"string-width-cjs@npm:string-width@^4.2.0":
6890+
version "4.2.3"
6891+
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
6892+
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
6893+
dependencies:
6894+
emoji-regex "^8.0.0"
6895+
is-fullwidth-code-point "^3.0.0"
6896+
strip-ansi "^6.0.1"
6897+
6898+
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
68976899
version "4.2.3"
68986900
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
68996901
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -6957,7 +6959,7 @@ string_decoder@~1.1.1:
69576959
dependencies:
69586960
safe-buffer "~5.1.0"
69596961

6960-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
6962+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
69616963
version "6.0.1"
69626964
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
69636965
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -6971,6 +6973,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.2.0:
69716973
dependencies:
69726974
ansi-regex "^4.1.0"
69736975

6976+
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
6977+
version "6.0.1"
6978+
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
6979+
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
6980+
dependencies:
6981+
ansi-regex "^5.0.1"
6982+
69746983
strip-ansi@^7.0.1:
69756984
version "7.1.0"
69766985
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
@@ -7344,10 +7353,10 @@ use-sync-external-store@^1.0.0:
73447353
resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a"
73457354
integrity sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==
73467355

7347-
use-sync-external-store@^1.2.2:
7348-
version "1.4.0"
7349-
resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.4.0.tgz#adbc795d8eeb47029963016cefdf89dc799fcebc"
7350-
integrity sha512-9WXSPC5fMv61vaupRkCKCxsPxBocVnwakBEkMIHHpkTTg6icbJtg6jzgtLDm4bl3cSHAca52rYWih0k4K3PfHw==
7356+
use-sync-external-store@^1.5.0:
7357+
version "1.5.0"
7358+
resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.5.0.tgz#55122e2a3edd2a6c106174c27485e0fd59bcfca0"
7359+
integrity sha512-Rb46I4cGGVBmjamjphe8L/UnvJD+uPPtTkNvX5mZgqdbavhI4EbgIWJiIHXJ8bc/i9EQGPRh4DwEURJ552Do0A==
73517360

73527361
use@^3.1.0:
73537362
version "3.1.1"
@@ -7513,7 +7522,7 @@ word-wrap@^1.2.3, word-wrap@~1.2.3:
75137522
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
75147523
integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==
75157524

7516-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
7525+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
75177526
version "7.0.0"
75187527
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
75197528
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -7531,6 +7540,15 @@ wrap-ansi@^6.2.0:
75317540
string-width "^4.1.0"
75327541
strip-ansi "^6.0.0"
75337542

7543+
wrap-ansi@^7.0.0:
7544+
version "7.0.0"
7545+
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
7546+
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
7547+
dependencies:
7548+
ansi-styles "^4.0.0"
7549+
string-width "^4.1.0"
7550+
strip-ansi "^6.0.0"
7551+
75347552
wrap-ansi@^8.1.0:
75357553
version "8.1.0"
75367554
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
@@ -7662,9 +7680,7 @@ yocto-queue@^0.1.0:
76627680
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
76637681
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
76647682

7665-
zustand@^4.5.2:
7666-
version "4.5.6"
7667-
resolved "https://registry.yarnpkg.com/zustand/-/zustand-4.5.6.tgz#6857d52af44874a79fb3408c9473f78367255c96"
7668-
integrity sha512-ibr/n1hBzLLj5Y+yUcU7dYw8p6WnIVzdJbnX+1YpaScvZVF2ziugqHs+LAmHw4lWO9c/zRj+K1ncgWDQuthEdQ==
7669-
dependencies:
7670-
use-sync-external-store "^1.2.2"
7683+
zustand@^5.0.6:
7684+
version "5.0.6"
7685+
resolved "https://registry.yarnpkg.com/zustand/-/zustand-5.0.6.tgz#a2da43d8dc3d31e314279e5baec06297bea70a5c"
7686+
integrity sha512-ihAqNeUVhe0MAD+X8M5UzqyZ9k3FFZLBTtqo6JLPwV53cbRB/mJwBI0PxcIgqhBBHlEs8G45OTDTMq3gNcLq3A==

0 commit comments

Comments
 (0)