@tramvai/react 7.11.0 → 7.16.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.
@@ -27,9 +27,11 @@ class UniversalErrorBoundary extends Component {
27
27
  componentDidCatch(error, errorInfo) {
28
28
  const { errorHandlers } = this.props;
29
29
  if (errorHandlers) {
30
- errorHandlers.forEach((handler) => {
31
- handler(error, errorInfo);
32
- });
30
+ if (errorHandlers) {
31
+ errorHandlers.forEach((handler) => {
32
+ handler(error, errorInfo);
33
+ });
34
+ }
33
35
  }
34
36
  }
35
37
  render() {
@@ -31,9 +31,11 @@ class UniversalErrorBoundary extends react.Component {
31
31
  componentDidCatch(error, errorInfo) {
32
32
  const { errorHandlers } = this.props;
33
33
  if (errorHandlers) {
34
- errorHandlers.forEach((handler) => {
35
- handler(error, errorInfo);
36
- });
34
+ if (errorHandlers) {
35
+ errorHandlers.forEach((handler) => {
36
+ handler(error, errorInfo);
37
+ });
38
+ }
37
39
  }
38
40
  }
39
41
  render() {
@@ -1,6 +1,10 @@
1
1
  import type React from 'react';
2
2
  import type { UniversalErrorBoundaryFallbackProps } from './UniversalErrorBoundary';
3
+ export type ErrorSeverity = 'critical' | 'error';
3
4
  type ErrorBoundaryHandler = (error: Error, errorInfo: React.ErrorInfo) => void;
5
+ /**
6
+ * @deprecated subsribe to `TRAMVAI_HOOKS_TOKEN['react:error']` hook instead, looking for the `page-error-boundary` event
7
+ */
4
8
  export declare const ERROR_BOUNDARY_TOKEN: ErrorBoundaryHandler & {
5
9
  __type?: "multi token" | undefined;
6
10
  };
@@ -1,5 +1,8 @@
1
1
  import { createToken } from '@tinkoff/dippy';
2
2
 
3
+ /**
4
+ * @deprecated subsribe to `TRAMVAI_HOOKS_TOKEN['react:error']` hook instead, looking for the `page-error-boundary` event
5
+ */
3
6
  const ERROR_BOUNDARY_TOKEN = createToken('reactErrorBoundaryHandlers', {
4
7
  multi: true,
5
8
  });
@@ -4,6 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var dippy = require('@tinkoff/dippy');
6
6
 
7
+ /**
8
+ * @deprecated subsribe to `TRAMVAI_HOOKS_TOKEN['react:error']` hook instead, looking for the `page-error-boundary` event
9
+ */
7
10
  const ERROR_BOUNDARY_TOKEN = dippy.createToken('reactErrorBoundaryHandlers', {
8
11
  multi: true,
9
12
  });
@@ -14,9 +14,13 @@ const resolveLazyComponent = async (componentOrLoader) => {
14
14
  else {
15
15
  component = mod.default || mod;
16
16
  }
17
- // manually hoist static properties from preloaded component to loadable wrapper,
18
- // this open access to current page component static properties outside before rendering
19
- hoistStatics(componentOrLoader, component);
17
+ if (!componentOrLoader.__tramvai_lazy_loaded) {
18
+ // small performance optimization to avoid hoisting the same static properties on every load (which already cached by loadable)
19
+ componentOrLoader.__tramvai_lazy_loaded = true;
20
+ // manually hoist static properties from preloaded component to loadable wrapper,
21
+ // this open access to current page component static properties outside before rendering
22
+ hoistStatics(componentOrLoader, component);
23
+ }
20
24
  return component;
21
25
  }
22
26
  return componentOrLoader;
package/lib/lazy/lazy.js CHANGED
@@ -23,9 +23,13 @@ const resolveLazyComponent = async (componentOrLoader) => {
23
23
  else {
24
24
  component = mod.default || mod;
25
25
  }
26
- // manually hoist static properties from preloaded component to loadable wrapper,
27
- // this open access to current page component static properties outside before rendering
28
- hoistStatics__default["default"](componentOrLoader, component);
26
+ if (!componentOrLoader.__tramvai_lazy_loaded) {
27
+ // small performance optimization to avoid hoisting the same static properties on every load (which already cached by loadable)
28
+ componentOrLoader.__tramvai_lazy_loaded = true;
29
+ // manually hoist static properties from preloaded component to loadable wrapper,
30
+ // this open access to current page component static properties outside before rendering
31
+ hoistStatics__default["default"](componentOrLoader, component);
32
+ }
29
33
  return component;
30
34
  }
31
35
  return componentOrLoader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/react",
3
- "version": "7.11.0",
3
+ "version": "7.16.0",
4
4
  "description": "",
5
5
  "main": "lib/react.js",
6
6
  "typings": "lib/react.d.ts",
@@ -18,12 +18,12 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@loadable/component": "^5.15.2",
21
- "@tramvai/types-actions-state-context": "7.11.0",
21
+ "@tramvai/types-actions-state-context": "7.16.0",
22
22
  "@types/loadable__component": "^5.13.4",
23
23
  "hoist-non-react-statics": "^3.3.0"
24
24
  },
25
25
  "peerDependencies": {
26
- "@tinkoff/dippy": "0.13.2",
26
+ "@tinkoff/dippy": "^1.0.0",
27
27
  "@tinkoff/url": "0.13.1",
28
28
  "@tinkoff/utils": "^2.1.2",
29
29
  "react": ">=16.14.0",