You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to know if there's an easy way to pass {t} as a props inside another components
hooks don't work inside loops so I need a way to find the type of t in order to pass it as prop in my other component
here an example:
const { scopedT } = useI18n();
const t = scopedT('table')
buildTableHeader(t);
export const buildHeadIncidents = (t: //What type should I put here): HeadCellItem[] => {
// const { t } = useI18n(); // I can't call the hook here
return [
{
name: 'title1',
label: t('mykey'),
},
{
name: 'title2',
label: t('mykey'),
},
{
name: 'title3',
label: t('mykey'),
}
];
};
Here is definition of t and scopedT used by next-international
You should be able to get the type of t or scopedT like this:
typeT=ReturnType<typeofuseI18n>['t']
But I'm not sure how that would play with scopedT. The easiest way might be to use international-types directly, something like:
// Locale is the type of your locale, same when using createI18n// 'table' is the scopeexportconstbuildHeadIncidents=(t: (key: LocaleKeys<typeofLocale,'table'>)=>string): HeadCellItem[]=>{return[{name: 'title1',label: t('mykey'),},{name: 'title2',label: t('mykey'),},{name: 'title3',label: t('mykey'),}];};
I would like to know if there's an easy way to pass {t} as a props inside another components
hooks don't work inside loops so I need a way to find the type of t in order to pass it as prop in my other component
here an example:
Here is definition of t and scopedT used by next-international
The text was updated successfully, but these errors were encountered: