Last active
February 7, 2024 09:52
-
-
Save klaytonfaria/d6a0f628c986e6453b4d5ef09f2f0488 to your computer and use it in GitHub Desktop.
React-native MessageQueue.spy use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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