Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New iOS tab is created every time I relaunch the app. #1387

Open
ubaidvalere opened this issue Dec 21, 2023 · 4 comments
Open

New iOS tab is created every time I relaunch the app. #1387

ubaidvalere opened this issue Dec 21, 2023 · 4 comments
Labels
bug 🪲 Nope, this is wrong.

Comments

@ubaidvalere
Copy link

image
@jamonholmgren jamonholmgren added the bug 🪲 Nope, this is wrong. label Jan 5, 2024
@jamonholmgren
Copy link
Member

This is a confirmed bug, and we have some ideas how we'll fix this. cc @joshuayoes

@joshuayoes
Copy link
Contributor

joshuayoes commented Jan 23, 2024

For now, this can be fixed by calling setAsyncStorageHandler like so

import Reactotron from "reactotron-react-native";
import { AsyncStorage } from "@react-native-async-storage/async-storage";

Reactotron
  .configure() 
  .useReactNative() 
  .setAsyncStorageHandler(AsyncStorage) // allows Reactotron to store an ID in async storage to prevent this from happening
  .connect(); 

@joshuayoes
Copy link
Contributor

joshuayoes commented Jan 23, 2024

If you are using another storage package like react-native-mmkv, you could also write your own getClientId
and setClientId functions

import { MMKV } from 'react-native-mmkv'
import Reactotron from 'reactotron-react-native'

const REACTOTRON_ASYNC_CLIENT_ID = "@REACTOTRON/clientId"

const storage = new MMKV({ id: REACTOTRON_ASYNC_CLIENT_ID })

const getClientId = async () => storage.getString(REACTOTRON_ASYNC_CLIENT_ID)!

const setClientId = async (clientId: string) => {
  storage.set(REACTOTRON_ASYNC_CLIENT_ID, clientId)
}

Reactotron.configure({
  getClientId,
  setClientId,
})
  .useReactNative()
  .connect()

@Ajmal0197
Copy link

Ajmal0197 commented Feb 6, 2024

New tab issue fixed as per @joshuayoes soln:

import Reactotron, { networking } from 'reactotron-react-native';
import { reactotronRedux } from 'reactotron-redux';
import mmkvPlugin from 'reactotron-react-native-mmkv';
import { MMKV } from 'react-native-mmkv';

const REACTOTRON_ASYNC_CLIENT_ID = '@REACTOTRON/clientId';
const storage = new MMKV({ id: REACTOTRON_ASYNC_CLIENT_ID });
const getClientId = async () => storage.getString(REACTOTRON_ASYNC_CLIENT_ID);
const setClientId = async (clientId) => {
  storage.set(REACTOTRON_ASYNC_CLIENT_ID, clientId);
};

Reactotron.configure({
  getClientId,
  setClientId,
})
  .useReactNative()
  .use(reactotronRedux()) //  <- here i am!
  .use(
    mmkvPlugin({
      storage, // mmkv instance
      ignore: ['secret', 'persist:root']
    })
  )
  .connect();

const yeOldeConsoleLog = console.log;
console.log = (...args) => {
  // always call the old one, because React Native does magic swizzling too
  yeOldeConsoleLog(...args);

  Reactotron.display({
    name: 'CONSOLE',
    value: args,
    preview: args.length > 0 && typeof args[0] === 'string' ? args[0] : null,
  });
};

export default Reactotron;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Nope, this is wrong.
Projects
None yet
Development

No branches or pull requests

4 participants