@arcblock/ux 2.9.80 → 2.9.81

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-prototype-builtins */
2
- import { createContext, useState, useEffect, useContext, useRef } from 'react';
2
+ import { createContext, useState, useEffect, useContext, useRef, useCallback } from 'react';
3
3
  import get from 'lodash/get';
4
4
  import PropTypes from 'prop-types';
5
5
  import Cookie from 'js-cookie';
@@ -102,7 +102,7 @@ function LocaleProvider({
102
102
  } else {
103
103
  lastCurrentLocale.current = currentLocale;
104
104
  }
105
- const t = (key, data) => translate(translations, key, currentLocale, fallbackLocale, data);
105
+ const t = useCallback((key, data) => translate(translations, key, currentLocale, fallbackLocale, data), [translations, currentLocale, fallbackLocale]);
106
106
  return /*#__PURE__*/_jsx(Provider, {
107
107
  value: {
108
108
  locale: currentLocale,
@@ -127,7 +127,7 @@ function LocaleProvider(_ref) {
127
127
  } else {
128
128
  lastCurrentLocale.current = currentLocale;
129
129
  }
130
- const t = (key, data) => (0, _util.translate)(translations, key, currentLocale, fallbackLocale, data);
130
+ const t = (0, _react.useCallback)((key, data) => (0, _util.translate)(translations, key, currentLocale, fallbackLocale, data), [translations, currentLocale, fallbackLocale]);
131
131
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Provider, {
132
132
  value: _objectSpread({
133
133
  locale: currentLocale,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.9.80",
3
+ "version": "2.9.81",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -361,12 +361,12 @@
361
361
  "react": ">=18.2.0",
362
362
  "react-router-dom": ">=6.22.3"
363
363
  },
364
- "gitHead": "42a44e1df8e44d948124a2f9a9b7713dfbe6219a",
364
+ "gitHead": "7e514618898ec98f3c2c062f76d3808f9c0eee14",
365
365
  "dependencies": {
366
366
  "@arcblock/did-motif": "^1.1.13",
367
- "@arcblock/icons": "^2.9.80",
368
- "@arcblock/nft-display": "^2.9.80",
369
- "@arcblock/react-hooks": "^2.9.80",
367
+ "@arcblock/icons": "^2.9.81",
368
+ "@arcblock/nft-display": "^2.9.81",
369
+ "@arcblock/react-hooks": "^2.9.81",
370
370
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
371
371
  "@fontsource/inter": "^5.0.16",
372
372
  "@fontsource/ubuntu-mono": "^5.0.18",
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-prototype-builtins */
2
- import { createContext, useState, useEffect, useContext, useRef } from 'react';
2
+ import { createContext, useState, useEffect, useContext, useRef, useCallback } from 'react';
3
3
  import get from 'lodash/get';
4
4
  import PropTypes from 'prop-types';
5
5
  import Cookie from 'js-cookie';
@@ -101,7 +101,10 @@ function LocaleProvider({ children, locale, fallbackLocale, translations, onLoad
101
101
  lastCurrentLocale.current = currentLocale;
102
102
  }
103
103
 
104
- const t = (key, data) => translate(translations, key, currentLocale, fallbackLocale, data);
104
+ const t = useCallback(
105
+ (key, data) => translate(translations, key, currentLocale, fallbackLocale, data),
106
+ [translations, currentLocale, fallbackLocale]
107
+ );
105
108
 
106
109
  return <Provider value={{ locale: currentLocale, changeLocale, t, languages: langs, ...rest }}>{children}</Provider>;
107
110
  }