diff --git a/native/data/sensitive-data-cleaner.react.js b/native/data/sensitive-data-cleaner.react.js
new file mode 100644
--- /dev/null
+++ b/native/data/sensitive-data-cleaner.react.js
@@ -0,0 +1,36 @@
+// @flow
+
+import * as React from 'react';
+import ExitApp from 'react-native-exit-app';
+
+import { useSelector } from '../redux/redux-utils';
+
+function SensitiveDataCleaner(): null {
+ const currentUserInfo = useSelector(state => state.currentUserInfo);
+ React.useEffect(() => {
+ try {
+ const databaseCurrentUserInfoID = global.CommCoreModule.getCurrentUserID();
+ const userLoggedOut =
+ !currentUserInfo || currentUserInfo.anonymous ? true : false;
+ if (
+ (userLoggedOut && databaseCurrentUserInfoID) ||
+ (databaseCurrentUserInfoID &&
+ currentUserInfo?.id !== databaseCurrentUserInfoID)
+ ) {
+ global.CommCoreModule.clearSensitiveData();
+ } else if (!userLoggedOut && !databaseCurrentUserInfoID) {
+ global.CommCoreModule.setCurrentUserID(currentUserInfo?.id);
+ }
+ } catch (e) {
+ if (__DEV__) {
+ throw e;
+ } else {
+ console.log(e);
+ ExitApp.exitApp();
+ }
+ }
+ }, [currentUserInfo]);
+ return null;
+}
+
+export { SensitiveDataCleaner };
diff --git a/native/root.react.js b/native/root.react.js
--- a/native/root.react.js
+++ b/native/root.react.js
@@ -22,6 +22,7 @@
import PersistedStateGate from './components/persisted-state-gate';
import ConnectedStatusBar from './connected-status-bar.react';
import CoreDataProvider from './data/core-data-provider.react';
+import { SensitiveDataCleaner } from './data/sensitive-data-cleaner.react';
import { SQLiteContextProvider } from './data/sqlite-context-provider';
import ErrorBoundary from './error-boundary.react';
import InputStateContainer from './input/input-state-container.react';
@@ -222,6 +223,7 @@
+
>
);
let navigation;