@tolgee/react 5.6.1 → 5.7.0-prerelease.134377fa.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/tagsTools.tsx CHANGED
@@ -20,9 +20,9 @@ export const wrapTagHandlers = (
20
20
  } else if (React.isValidElement(value as any)) {
21
21
  const el = value as React.ReactElement;
22
22
  result[key] = (chunk: any) => {
23
- return el.props.children === undefined && chunk?.length
24
- ? React.cloneElement(el, {}, addReactKeys(chunk))
25
- : React.cloneElement(el);
23
+ return el.props.children !== undefined
24
+ ? React.cloneElement(el)
25
+ : React.cloneElement(el, {}, addReactKeys(chunk));
26
26
  };
27
27
  } else {
28
28
  result[key] = value;
@@ -1,16 +1,26 @@
1
1
  import { useCallback } from 'react';
2
- import { TFnType, getTranslateProps, DefaultParamType } from '@tolgee/web';
2
+ import {
3
+ TFnType,
4
+ getTranslateProps,
5
+ DefaultParamType,
6
+ TranslationKey,
7
+ } from '@tolgee/web';
3
8
 
4
9
  import { useTranslateInternal } from './useTranslateInternal';
5
10
  import { ReactOptions } from './types';
6
11
 
12
+ type UseTranslateResult = {
13
+ t: TFnType<DefaultParamType, string, TranslationKey>;
14
+ isLoading: boolean;
15
+ };
16
+
7
17
  export const useTranslate = (
8
18
  ns?: string[] | string,
9
19
  options?: ReactOptions
10
- ) => {
20
+ ): UseTranslateResult => {
11
21
  const { t: tInternal, isLoading } = useTranslateInternal(ns, options);
12
22
 
13
- const t: TFnType<DefaultParamType, string> = useCallback(
23
+ const t = useCallback(
14
24
  (...params: any) => {
15
25
  // @ts-ignore
16
26
  const props = getTranslateProps(...params);