try {
const msgFormatter = new IntlMessageFormat(msg, currentLocale, formats);
return msgFormatter.format(variables);
} catch (err) {
this.options.warningHandler(
`react-intl-universal format message failed for key='${key}'.`,
err.message
);
return msg;
}
No matter whether the get method passes variables or not, it will always take the IntlMessageFormat method. I don't think this is necessary. If there is no variables parameter, it can return msg directly, IntlMessageFormat will cause additional performance consumption.
If you don't pass variables, I think you can return msg directly, for example:
if (variables) {
...
+ } else {
+ return msg;
}
try {
const msgFormatter = new IntlMessageFormat(msg, currentLocale, formats);
return msgFormatter.format(variables);
} catch (err) {
this.options.warningHandler(
`react-intl-universal format message failed for key='${key}'.`,
err.message
);
return msg;
}
In the actual project has encountered serious performance problems, currently using patch-package to hit patch to solve, It would be great if we could merge pr.
If you don't pass variables, I think you can return msg directly, for example: