Skip to content

Commit c520624

Browse files
committed
Fix errors
1 parent 4eb6c57 commit c520624

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

library/src/assets/icon/babel-plugin/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type * as t from '@babel/types';
33
import type * as i from '@iconify/react/dist/iconify.js';
44

55
import {stringToIcon, getIconData} from '@iconify/utils';
6-
import {readdirSync, readFileSync, writeFileSync, mkdirSync, existsSync} from 'node:fs';
6+
import {readdirSync, readFileSync, writeFileSync, mkdirSync, existsSync} from 'fs';
77

88
export const loadedIcons = new Map<string, boolean>();
99
export const iconJsonCache = new Map<string, i.IconifyJSON>();

library/src/utilities/useVariants.ts

+17-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {useMemo, useCallback} from 'react';
1+
import {useMemo} from 'react';
22
import {titleCase} from '_lib/string';
33

44
import type {PressableStateCallbackType} from 'react-native';
@@ -18,19 +18,17 @@ export function useVariants<S>(
1818
): {
1919
vstyles: VStyleSheet<S>,
2020
} {
21-
const isVState = useCallback((v: string): boolean =>
22-
v.toLowerCase() === 'state'
23-
, []);
21+
const isVState = (v: string): boolean => v.toLowerCase() === 'state';
2422

25-
const buildStyles = useCallback((slug: VStyleKey<S>, styles: S) => {
23+
const buildStyles = (slug: VStyleKey<S>, styles: S) => {
2624
const vstyles: [VStyleCond, VStyleMod<S>][] = [[null, styles[slug]]];
2725
const vnames = Object.entries(variants).sort((a, b) => a[0].localeCompare(b[0]));
2826
// Sort and and loop through all vars
29-
for (const [v1, primary] of vnames) {
27+
vnames.forEach(([v1, primary]) => {
3028
// Single variant for this component
3129
if (vnames.length === 1) {
3230
// Loop through all values for the variant
33-
for (const v1v of primary) {
31+
primary.forEach(v1v => {
3432
// Build id for this variant combination
3533
const vkey = `${slug}${titleCase(v1)}${v1v}` as VStyleKey<S>;
3634
// Look up the id in the stylesheet
@@ -46,18 +44,18 @@ export function useVariants<S>(
4644
);
4745
// Add the variant combo style to styles
4846
vstyles.push([vcond, vstyle]);
49-
}
47+
});
5048
// Multiple variants, create compound styles
5149
} else {
5250
// Prevent state from being used as primary variant (it's a secondary)
5351
if (isVState(v1)) return;
5452
// Loop through all values for the variant
55-
for (const v1v of primary) {
53+
primary.forEach(v1v => {
5654
// For this value, loop all values of the other variants
57-
for (const [v2, secondary] of vnames) {
55+
vnames.forEach(([v2, secondary]) => {
5856
if (v1 === v2) return;
5957
// Loop through all the values in the other variant
60-
for (const v2v of secondary) {
58+
secondary.forEach(v2v => {
6159
// Build id for this variant combination
6260
const vkey = `${slug}${titleCase(v1)}${v1v}${titleCase(v2)}${v2v}` as VStyleKey<S>;
6361
// Look up the id in the stylesheet
@@ -75,15 +73,15 @@ export function useVariants<S>(
7573
);
7674
// Add the variant combo style to styles
7775
vstyles.push([vcond, vstyle]);
78-
}
79-
}
80-
}
76+
});
77+
});
78+
});
8179
}
82-
}
80+
});
8381
return vstyles;
84-
}, [variants, states, isVState]);
82+
}
8583

86-
const proxyStyles = useCallback((o: S): VStyleSheet<S> => {
84+
const proxyStyles = (o: S): VStyleSheet<S> => {
8785
// Cache the styles for each variant combo as they are accessed
8886
const cache = new Map<string, ReturnType<typeof buildStyles>>();
8987
// Create empty object to proxy the styles, inherit types from stylesheet
@@ -98,18 +96,16 @@ export function useVariants<S>(
9896
styles = buildStyles(k, o);
9997
cache.set(k, styles);
10098
}
101-
// Still no styles found, return empty array
102-
if (!styles) return [];
10399
// Return styles that match the current variant values and/or state
104100
return styles
105101
.filter(([c]) => c === null || c?.(e))
106102
.map(([,s]) => s);
107103
};
108104
}
109105
return proxy;
110-
}, [buildStyles]);
106+
};
111107

112108
return {
113-
vstyles: useMemo(() => proxyStyles(styles), [styles, proxyStyles]),
109+
vstyles: useMemo(() => proxyStyles(styles), [styles]),
114110
};
115111
}

toolkit/config/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "0.0.0",
55
"private": true,
66
"scripts": {
7-
"build": "pnpm gen:locales && tsc && pnpm gen:cfg && pnpm gen:files",
7+
"build": "pnpm gen:cfg && pnpm gen:locales && tsc && pnpm gen:files",
88
"gen:cfg": "rnuc --project-root ../../client --lib-root ./node_modules/react-native-ultimate-config ../../config.yaml",
99
"gen:files": "node ./scripts/gen-app-json.js && node ./scripts/gen-docs-sidebar.js",
1010
"gen:locales": "node ./scripts/gen-user-locales.js"

0 commit comments

Comments
 (0)