Using
const MATCHED_CONTACTS = (count: number) =>
fbt(
fbt.plural('', count, {
many: 'Matches ',
}) +
fbt.plural('', count, {
name: 'number of matched contacts',
many: 'contacts:',
showCount: 'ifMany',
}),
'Call.numberOfMatchedContacts',
).toString();
...
<Text style={styles.result}>
{MATCHED_CONTACTS(1)}
</Text>
Trigger the following error. It happens only with one other number, which works fine.
Error: Table access did not result in string: {"*":{"*":"Matches {number of matched contacts} contacts:"},"_1":{"_1":""}}, Type: object
at _ (index.mjs:1851:58)
at MATCHED_CONTACTS (FbteeExample.tsx:9:5)
at FbteeExample (FbteeExample.tsx:35:28)
at react_stack_bottom_frame (ReactFabric-dev.js:15887:29)
at renderWithHooks (ReactFabric-dev.js:3857:40)
at updateFunctionComponent (ReactFabric-dev.js:7289:34)
at beginWork (ReactFabric-dev.js:8541:41)
at runWithFiberInDEV (ReactFabric-dev.js:683:21)
at performUnitOfWork (ReactFabric-dev.js:12218:39)
at workLoopSync (ReactFabric-dev.js:12042:58)
at renderRootSync (ReactFabric-dev.js:12022:23)
at performWorkOnRoot (ReactFabric-dev.js:11585:53)
at performSyncWorkOnRoot (ReactFabric-dev.js:3088:24)
at flushSyncWorkAcrossRoots_impl (ReactFabric-dev.js:2942:42)
at processRootScheduleInMicrotask (ReactFabric-dev.js:2973:36)
at anonymous (ReactFabric-dev.js:3108:47) Error Stack:
at AppContent (App.tsx:28:7)
at App (App.tsx:20:7)
See repo: https://github.com/dprevost-LMI/rn82/tree/fbtee
Claude suggested a patch:
diff --git a/node_modules/fbtee/lib/index.mjs b/node_modules/fbtee/lib/index.mjs
index aacf97e..2e20ae7 100644
--- a/node_modules/fbtee/lib/index.mjs
+++ b/node_modules/fbtee/lib/index.mjs
@@ -1842,7 +1842,14 @@ function createRuntime({ getResult, param, plural }) {
if (args) {
if (typeof table !== "string") {
const newPattern = FbtTable_default.access(table, args, 0, tokens);
- if (newPattern) table = newPattern;
+ if (newPattern) {
+ table = newPattern;
+ } else {
+ // Handle case where table access returns null
+ // This happens when fbt.plural has empty string as singular form
+ // Return empty string to preserve the intended behavior
+ table = "";
+ }
}
invariant(table !== null, "Table access failed");
substitutions = getAllSubstitutions(args);
Using
Trigger the following error. It happens only with one other number, which works fine.
See repo: https://github.com/dprevost-LMI/rn82/tree/fbtee
Claude suggested a patch: