79305698

Date: 2024-12-24 13:30:21
Score: 2
Natty:
Report link

I used this post to get to my answer although my issue was more generic (just parse an array of strings in my translations file). I am also using typescript. In case anyone here is stuck with the same issue: you can access the messages as kate shows above, but in typescript you also must first cast the object as unknown first before casting it to a string[] which can then be mapped normally.

const intl = useIntl(); 
const safetyTips = intl.messages["safety-tips"] as unknown as string[];
console.log(safetyTips);

<ul>
  {safetyTips.map((tip, index) => (
    <li key={index}>{tip}</li>
  ))}
</ul>
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): stuck with the same issue
  • Low reputation (0.5):
Posted by: I_Literally_Cannot