mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 18:46:17 +00:00
Since we are using the react-i18n babel loader plugin, useI18n can only be used once per file. Also we have to remember to add the istanbul ignore next comment each time we use it. By moving this to a common file, it can be easily copied and pasted when a new submodule is created and we don't have to remember the rules when calling it.
25 lines
595 B
TypeScript
25 lines
595 B
TypeScript
// SPDX-License-Identifier: MIT
|
|
// Copyright (c) 2021-2022 The Pybricks Authors
|
|
|
|
// provides translation for notification text
|
|
|
|
import { Replacements } from '@shopify/react-i18n';
|
|
import React from 'react';
|
|
import { I18nId, useI18n } from './i18n';
|
|
|
|
type NotificationActionProps = {
|
|
messageId: I18nId;
|
|
replacements?: Replacements;
|
|
};
|
|
|
|
const NotificationAction: React.VoidFunctionComponent<NotificationActionProps> = ({
|
|
messageId,
|
|
replacements,
|
|
}) => {
|
|
const i18n = useI18n();
|
|
|
|
return <>{i18n.translate(messageId, replacements)}</>;
|
|
};
|
|
|
|
export default NotificationAction;
|