@graphcommerce/next-ui 9.0.0-canary.72 → 9.0.0-canary.74
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 +8 -0
- package/Intl/ListFormat.tsx +3 -2
- package/hooks/index.ts +1 -0
- package/hooks/memoDeep.ts +38 -0
- package/package.json +8 -8
- package/server.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 9.0.0-canary.74
|
|
4
|
+
|
|
5
|
+
## 9.0.0-canary.73
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- [`4c24225`](https://github.com/graphcommerce-org/graphcommerce/commit/4c24225f9f998cd40e71da06528eb9323e9b6752) - Created a new `memoDeep` function that is a deep compare variant of `React.memo`. Performance seems to be pretty good, but should only be used as a result of a profiling session. ([@paales](https://github.com/paales))
|
|
10
|
+
|
|
3
11
|
## 9.0.0-canary.72
|
|
4
12
|
|
|
5
13
|
## 9.0.0-canary.71
|
package/Intl/ListFormat.tsx
CHANGED
|
@@ -22,8 +22,9 @@ export function ListFormat(props: ListFormatProps) {
|
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<>
|
|
25
|
-
{parts.map((part) => (
|
|
26
|
-
|
|
25
|
+
{parts.map((part, index) => (
|
|
26
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
27
|
+
<React.Fragment key={index}>
|
|
27
28
|
{part.type === 'literal' ? part.value : childArray[part.value]}
|
|
28
29
|
</React.Fragment>
|
|
29
30
|
))}
|
package/hooks/index.ts
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
+
import { equal } from '@wry/equality'
|
|
3
|
+
import { FunctionComponent, memo, NamedExoticComponent } from 'react'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This is a deep comparison version of React's `memo` function.
|
|
7
|
+
*
|
|
8
|
+
* This method isn't too expensive to run, but will be rerun every time a parent component is rendered.
|
|
9
|
+
*
|
|
10
|
+
* This should probably only be used as the result of a performance profiling session.
|
|
11
|
+
*/
|
|
12
|
+
export function memoDeep<P extends object>(
|
|
13
|
+
Component: FunctionComponent<P>,
|
|
14
|
+
measure: boolean = false,
|
|
15
|
+
): NamedExoticComponent<P> {
|
|
16
|
+
return memo(
|
|
17
|
+
Component,
|
|
18
|
+
process.env.NODE_ENV === 'development' && measure
|
|
19
|
+
? (prevProps, nextProps) => {
|
|
20
|
+
const start = performance.now()
|
|
21
|
+
const result = equal(prevProps, nextProps)
|
|
22
|
+
const ms = performance.now() - start
|
|
23
|
+
|
|
24
|
+
if (ms < 0.2) return result
|
|
25
|
+
|
|
26
|
+
console.log(`memoDeep took more than 0.2ms`, {
|
|
27
|
+
result,
|
|
28
|
+
ms,
|
|
29
|
+
Component,
|
|
30
|
+
prevProps,
|
|
31
|
+
nextProps,
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
return result
|
|
35
|
+
}
|
|
36
|
+
: equal,
|
|
37
|
+
)
|
|
38
|
+
}
|
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": "9.0.0-canary.
|
|
5
|
+
"version": "9.0.0-canary.74",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"typescript": "5.5.3"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.
|
|
30
|
-
"@graphcommerce/framer-next-pages": "^9.0.0-canary.
|
|
31
|
-
"@graphcommerce/framer-scroller": "^9.0.0-canary.
|
|
32
|
-
"@graphcommerce/framer-utils": "^9.0.0-canary.
|
|
33
|
-
"@graphcommerce/image": "^9.0.0-canary.
|
|
34
|
-
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.
|
|
35
|
-
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.
|
|
29
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.74",
|
|
30
|
+
"@graphcommerce/framer-next-pages": "^9.0.0-canary.74",
|
|
31
|
+
"@graphcommerce/framer-scroller": "^9.0.0-canary.74",
|
|
32
|
+
"@graphcommerce/framer-utils": "^9.0.0-canary.74",
|
|
33
|
+
"@graphcommerce/image": "^9.0.0-canary.74",
|
|
34
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.74",
|
|
35
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.74",
|
|
36
36
|
"@lingui/core": "^4.2.1",
|
|
37
37
|
"@lingui/macro": "^4.2.1",
|
|
38
38
|
"@lingui/react": "^4.2.1",
|
package/server.ts
CHANGED