storybook-react-i18next
Advanced tools
Comparing version 1.0.10 to 1.0.11
@@ -0,1 +1,14 @@ | ||
# v1.0.11 (Mon Oct 18 2021) | ||
#### ⚠️ Pushed to `main` | ||
- update libs ([@stevensacks](https://github.com/stevensacks)) | ||
- fix race condition with <Trans> elements with short delay ([@stevensacks](https://github.com/stevensacks)) | ||
#### Authors: 1 | ||
- Steven Sacks ([@stevensacks](https://github.com/stevensacks)) | ||
--- | ||
# v1.0.9 (Fri Sep 24 2021) | ||
@@ -2,0 +15,0 @@ |
@@ -30,2 +30,4 @@ "use strict"; | ||
var withI18Next = function withI18Next(story, context) { | ||
var i18n = context.parameters.i18n; | ||
var _useGlobals = (0, _clientApi.useGlobals)(), | ||
@@ -35,6 +37,19 @@ _useGlobals2 = _slicedToArray(_useGlobals, 1), | ||
var i18n = context.parameters.i18n; | ||
var _useState = (0, _react.useState)(true), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
show = _useState2[0], | ||
setShow = _useState2[1]; | ||
var timeoutRef = (0, _react.useRef)(null); | ||
(0, _react.useEffect)(function () { | ||
if (locale) { | ||
if (timeoutRef.current) { | ||
clearTimeout(timeoutRef.current); | ||
} | ||
setShow(false); | ||
i18n === null || i18n === void 0 ? void 0 : i18n.changeLanguage(locale); | ||
timeoutRef.current = setTimeout(function () { | ||
return setShow(true); | ||
}, 100); | ||
} // eslint-disable-next-line react-hooks/exhaustive-deps | ||
@@ -44,3 +59,3 @@ | ||
if (i18n) { | ||
if (i18n && show) { | ||
return /*#__PURE__*/_react["default"].createElement(_react.Suspense, { | ||
@@ -47,0 +62,0 @@ fallback: "Loading..." |
@@ -13,3 +13,3 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
import React, { useEffect, Suspense, Fragment } from "react"; | ||
import React, { useEffect, useRef, useState, Suspense, Fragment } from "react"; | ||
import { useGlobals } from '@storybook/client-api'; | ||
@@ -20,2 +20,4 @@ import { addDecorator } from '@storybook/react'; | ||
var withI18Next = function withI18Next(story, context) { | ||
var i18n = context.parameters.i18n; | ||
var _useGlobals = useGlobals(), | ||
@@ -25,6 +27,19 @@ _useGlobals2 = _slicedToArray(_useGlobals, 1), | ||
var i18n = context.parameters.i18n; | ||
var _useState = useState(true), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
show = _useState2[0], | ||
setShow = _useState2[1]; | ||
var timeoutRef = useRef(null); | ||
useEffect(function () { | ||
if (locale) { | ||
if (timeoutRef.current) { | ||
clearTimeout(timeoutRef.current); | ||
} | ||
setShow(false); | ||
i18n === null || i18n === void 0 ? void 0 : i18n.changeLanguage(locale); | ||
timeoutRef.current = setTimeout(function () { | ||
return setShow(true); | ||
}, 100); | ||
} // eslint-disable-next-line react-hooks/exhaustive-deps | ||
@@ -34,3 +49,3 @@ | ||
if (i18n) { | ||
if (i18n && show) { | ||
return /*#__PURE__*/React.createElement(Suspense, { | ||
@@ -37,0 +52,0 @@ fallback: "Loading..." |
{ | ||
"name": "storybook-react-i18next", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "Add react-i18next support to Storybook", | ||
@@ -47,18 +47,18 @@ "keywords": [ | ||
"dependencies": { | ||
"storybook-i18n": "^1.0.4" | ||
"storybook-i18n": "^1.0.6" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.15.7", | ||
"@babel/core": "^7.15.5", | ||
"@babel/preset-env": "^7.15.6", | ||
"@babel/core": "^7.15.8", | ||
"@babel/preset-env": "^7.15.8", | ||
"@babel/preset-react": "^7.14.5", | ||
"@babel/preset-typescript": "^7.14.5", | ||
"@storybook/addon-essentials": "^6.3.8", | ||
"@storybook/react": "^6.3.8", | ||
"auto": "^10.32.0", | ||
"@babel/preset-typescript": "^7.15.0", | ||
"@storybook/addon-essentials": "^6.3.12", | ||
"@storybook/react": "^6.3.12", | ||
"auto": "^10.32.1", | ||
"babel-loader": "^8.1.0", | ||
"boxen": "^5.1.2", | ||
"concurrently": "^6.2.1", | ||
"concurrently": "^6.3.0", | ||
"dedent": "^0.7.0", | ||
"i18next": "^21.0.2", | ||
"i18next": "^21.3.2", | ||
"prettier": "^2.4.1", | ||
@@ -70,3 +70,3 @@ "prop-types": "^15.7.2", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.4.3", | ||
"typescript": "^4.4.4", | ||
"zx": "^1.14.1" | ||
@@ -73,0 +73,0 @@ }, |
33721
146
Updatedstorybook-i18n@^1.0.6