React

Expensive computation

import { memo } from 'react'
const countrvList = ['United States', 'Senegal', 'Canada' ];
const SlowList = memo ( ({ search }) = {
    // - Simulate expensive computation starts
    const now = performance. now () ;
    while (performance. now () - now < 40) {}
    // - Simulate expensive compmutation ends
    return countryList.filter ((el) = el. indexof (search) > 0) ;
})

react-i18next

{
  "newCardRequest": "<0>❗New Card Request\u00A0</0><1>for {{initiatorName}}</1>"
}

import React from 'react';
import { useTranslation, Trans } from 'react-i18next';
import styles from './YourComponent.module.css'; // Assuming your styles are in this file

const YourComponent = ({ initiatorName, maskedCardNumber }) => {
  const { t } = useTranslation();

  return (
    <div className={styles.title}>
      <Trans
        i18nKey="newCardRequest" // The key from your translation file
        values={{ initiatorName }} // The dynamic value
        components={[
          <div className={styles.noOverflow} />, // Corresponds to <0>
          <div className={styles.noOverflow} />, // Corresponds to <1>
        ]}
      />
      <div>{maskedCardNumber}</div>
    </div>
  );
};

export default YourComponent;

Last updated

Was this helpful?