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
After spending several hours trying to solve this problem, I haven't had much luck.
I'm trying to map data to a navigation menu, but I don't want to have to manually specify the number of links each time I add something new in the future.
In my 'en.json' file, I have the following data: { "Navigation": { "appName": "xxx", "userButton": "My Account", "NavLinks": { "0": { "title": "about", "link": "#" }, "1": { "title": "demo", "link": "#" }, "2": { "title": "pricing", "link": "#" } } } }
.I'm encountering an error with the constant keys. The message says "Property NavLinks does not exist on type string or AbstractIntlMessages"
The only way I can get it to work without errors is by moving the NavLinks inside en.json to a separate object (outside of Navigation). However, this isn't a very elegant solution in my opinion. Thanks for any help!"
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi there,
After spending several hours trying to solve this problem, I haven't had much luck.
I'm trying to map data to a navigation menu, but I don't want to have to manually specify the number of links each time I add something new in the future.
In my 'en.json' file, I have the following data:
{ "Navigation": { "appName": "xxx", "userButton": "My Account", "NavLinks": { "0": { "title": "about", "link": "#" }, "1": { "title": "demo", "link": "#" }, "2": { "title": "pricing", "link": "#" } } } }
and my navigation component:
`
const t = useTranslations("Navigation.NavLinks");
const messages = useMessages();
const keys = Object.keys(messages.Navigation.NavLinks);
`
.I'm encountering an error with the constant keys. The message says "Property NavLinks does not exist on type string or AbstractIntlMessages"
The only way I can get it to work without errors is by moving the NavLinks inside en.json to a separate object (outside of Navigation). However, this isn't a very elegant solution in my opinion. Thanks for any help!"
Beta Was this translation helpful? Give feedback.
All reactions