@graphcommerce/ecommerce-ui 1.1.6 → 1.1.9
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 +26 -0
- package/components/WaitForQueries/WaitForQueries.tsx +11 -15
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @graphcommerce/ecommerce-ui
|
|
2
2
|
|
|
3
|
+
## 1.1.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`6ce2cbaf2`](https://github.com/graphcommerce-org/graphcommerce/commit/6ce2cbaf2cf27e21b753f7cb71e7e74826294de6), [`6ce2cbaf2`](https://github.com/graphcommerce-org/graphcommerce/commit/6ce2cbaf2cf27e21b753f7cb71e7e74826294de6)]:
|
|
8
|
+
- @graphcommerce/graphql@3.4.5
|
|
9
|
+
- @graphcommerce/next-ui@4.18.0
|
|
10
|
+
|
|
11
|
+
## 1.1.8
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`49370878a`](https://github.com/graphcommerce-org/graphcommerce/commit/49370878a48b90a4579026a7c56c54f97840cebb), [`b6ce5548c`](https://github.com/graphcommerce-org/graphcommerce/commit/b6ce5548c66a8ca62d3aee29467045f7f07f30c8)]:
|
|
16
|
+
- @graphcommerce/graphql@3.4.4
|
|
17
|
+
- @graphcommerce/next-ui@4.17.0
|
|
18
|
+
|
|
19
|
+
## 1.1.7
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#1575](https://github.com/graphcommerce-org/graphcommerce/pull/1575) [`199dc8599`](https://github.com/graphcommerce-org/graphcommerce/commit/199dc859989c376281243b59a59addc35138f119) Thanks [@paales](https://github.com/paales)! - WaitForQueries should also accept undefined when there is nothing to actually wait for
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [[`02023d8d8`](https://github.com/graphcommerce-org/graphcommerce/commit/02023d8d89c8138144243edce67290bd79ff49a7), [`87a188d6f`](https://github.com/graphcommerce-org/graphcommerce/commit/87a188d6f216b7f7b9ec95afbe74f1146cb07ce4), [`1eb131766`](https://github.com/graphcommerce-org/graphcommerce/commit/1eb131766c32db6fcb0a8e83dba2c3d241658595)]:
|
|
26
|
+
- @graphcommerce/react-hook-form@3.3.2
|
|
27
|
+
- @graphcommerce/next-ui@4.16.0
|
|
28
|
+
|
|
3
29
|
## 1.1.6
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
import { useIsomorphicLayoutEffect } from '@graphcommerce/framer-utils'
|
|
2
1
|
import { QueryResult } from '@graphcommerce/graphql'
|
|
3
|
-
import React, { startTransition, useState } from 'react'
|
|
2
|
+
import React, { startTransition, useEffect, useState } from 'react'
|
|
4
3
|
|
|
5
4
|
export type WaitForQueriesProps = {
|
|
6
|
-
waitFor: QueryResult<any, any> | QueryResult<any, any>[]
|
|
5
|
+
waitFor: QueryResult<any, any> | QueryResult<any, any>[] | undefined
|
|
7
6
|
children: React.ReactNode
|
|
8
7
|
fallback?: React.ReactNode
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
/**
|
|
12
|
-
* Shows the fallback during: SSR, Hydration and Query Loading.
|
|
13
|
-
*
|
|
14
|
-
* Why not use suspense? Not support with Apollo Client yet!
|
|
15
|
-
*/
|
|
10
|
+
/** Shows the fallback during: SSR, Hydration and Query Loading. */
|
|
16
11
|
export const WaitForQueries = (props: WaitForQueriesProps) => {
|
|
17
12
|
const { waitFor, fallback, children } = props
|
|
18
13
|
|
|
19
|
-
//
|
|
14
|
+
// Make sure the first render is always the same as the server.
|
|
15
|
+
// Make sure we we use startTransition to make sure we don't get into trouble with Suspense.
|
|
16
|
+
const [mounted, setMounted] = useState(false)
|
|
17
|
+
useEffect(() => startTransition(() => setMounted(true)), [])
|
|
18
|
+
|
|
19
|
+
// We are done when all queries either have data or an error.
|
|
20
20
|
const isDone = (Array.isArray(waitFor) ? waitFor : [waitFor]).every(
|
|
21
|
-
(
|
|
21
|
+
(res) => typeof res === 'undefined' || res.data || res.error,
|
|
22
22
|
)
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
const [mountedState, setMountedState] = useState(false)
|
|
26
|
-
useIsomorphicLayoutEffect(() => startTransition(() => setMountedState(true)), [])
|
|
27
|
-
|
|
28
|
-
return <>{isDone && mountedState ? children : fallback}</>
|
|
24
|
+
return <>{isDone && mounted ? children : fallback}</>
|
|
29
25
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/ecommerce-ui",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.9",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@graphcommerce/framer-utils": "3.1.4",
|
|
16
|
-
"@graphcommerce/next-ui": "4.
|
|
17
|
-
"@graphcommerce/react-hook-form": "3.3.
|
|
18
|
-
"@graphcommerce/graphql": "3.4.
|
|
16
|
+
"@graphcommerce/next-ui": "4.18.0",
|
|
17
|
+
"@graphcommerce/react-hook-form": "3.3.2",
|
|
18
|
+
"@graphcommerce/graphql": "3.4.5"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@graphcommerce/eslint-config-pwa": "^4.1.9",
|