Skip to content

Instantly share code, notes, and snippets.

@klaytonfaria
Last active February 7, 2024 09:52
Show Gist options
  • Save klaytonfaria/d6a0f628c986e6453b4d5ef09f2f0488 to your computer and use it in GitHub Desktop.
Save klaytonfaria/d6a0f628c986e6453b4d5ef09f2f0488 to your computer and use it in GitHub Desktop.
React-native MessageQueue.spy use
import React from 'react';
import {AppRegistry} from 'react-native';
import MainScreen from './screens/main';
import relayContainer from 'shared/relay-container';
import MessageQueue from 'react-native/Libraries/BatchedBridge/MessageQueue';
AppRegistry.registerComponent('MainScreen', () => relayContainer(MainScreen));
// Disable warning box on development mode
console.disableYellowBox = true;
// Spy debugging
if (__DEV__) {
const logSpy = (info) => {
const fromTo = info.type === 0 ? 'TO JS: ' : 'TO ANDROID: ';
const methodSignature = info.module + '.' + info.method + '(' + JSON.stringify(info.args) + ')';
console.log('spy: ', fromTo + methodSignature);
};
MessageQueue.spy(logSpy);
}
export default class App extends React.Component {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment