secullum-react-native-ui 4.15.2-beta.1 → 4.15.2-beta.3

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.
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import { NativeEventSubscription } from 'react-native';
2
3
  import DrawerLayout from 'react-native-drawer-layout';
3
4
  import { MenuProperties } from './Menu';
4
5
  export declare type MenuMobileProperties = MenuProperties & {
@@ -12,6 +13,7 @@ export interface MenuMobileState {
12
13
  }
13
14
  export declare class MenuMobile extends React.Component<MenuMobileProperties, MenuMobileState> {
14
15
  state: MenuMobileState;
16
+ backButtonHandlerSubscription: NativeEventSubscription | null;
15
17
  drawer: DrawerLayout | null;
16
18
  componentDidMount(): void;
17
19
  componentWillUnmount(): void;
@@ -13,6 +13,7 @@ class MenuMobile extends React.Component {
13
13
  this.state = {
14
14
  opened: false
15
15
  };
16
+ this.backButtonHandlerSubscription = null;
16
17
  this.drawer = null;
17
18
  this.handleBackButton = () => {
18
19
  if (this.state.opened) {
@@ -73,14 +74,21 @@ class MenuMobile extends React.Component {
73
74
  };
74
75
  }
75
76
  componentDidMount() {
76
- react_native_1.BackHandler.addEventListener('hardwareBackPress', this.handleBackButton);
77
+ this.backButtonHandlerSubscription = react_native_1.BackHandler.addEventListener('hardwareBackPress', this.handleBackButton);
77
78
  }
78
79
  componentWillUnmount() {
79
- react_native_1.BackHandler.removeEventListener('hardwareBackPress', this.handleBackButton);
80
+ if (this.backButtonHandlerSubscription) {
81
+ this.backButtonHandlerSubscription.remove();
82
+ }
80
83
  }
81
84
  render() {
82
85
  const theme = (0, theme_1.getTheme)();
83
- return (React.createElement(react_native_drawer_layout_1.default, { ref: drawer => (this.drawer = drawer), drawerLockMode: this.props.drawerLockMode, drawerBackgroundColor: theme.backgroundColor1, drawerWidth: (0, layout_1.isTablet)() ? 450 : 300, drawerPosition: react_native_drawer_layout_1.default.positions.Left, renderNavigationView: this.renderNavigationView, onDrawerOpen: () => this.setState({ opened: true }), onDrawerClose: () => this.setState({ opened: false }) }, this.props.children));
86
+ return (React.createElement(react_native_drawer_layout_1.default, { ref: drawer => (this.drawer = drawer), drawerLockMode: this.props.drawerLockMode, drawerBackgroundColor: theme.backgroundColor1, drawerWidth: (0, layout_1.isTablet)() ? 450 : 300, drawerPosition: react_native_drawer_layout_1.default.positions.Left, renderNavigationView: this.renderNavigationView, onDrawerOpen: () => this.setState({ opened: true }),
87
+ // When closing the app, we encountered the error 'useInsertionEffect must not schedule updates',
88
+ // because we were trying to update the state during the component render cycle. To avoid this,
89
+ // a setTimeout was introduced with a small delay (enough time to complete the render) before executing other functions.
90
+ // Related issue on GitLab: 11635
91
+ onDrawerClose: () => setTimeout(() => this.setState({ opened: false }), 1) }, this.props.children));
84
92
  }
85
93
  }
86
94
  exports.MenuMobile = MenuMobile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "secullum-react-native-ui",
3
- "version": "4.15.2-beta.1",
3
+ "version": "4.15.2-beta.3",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "files": [