I am using below code to print console log in react native, but i am getting error cannot find variable v:
import React,
{
AppRegistry,
Component,
StyleSheet,
Text,
View,
} from 'react-native';
var ConsolePanel = require('react-native-console-panel').displayWhenDev();
class RanD extends Component {
render() {
return (
<View style={styles.container}>
<Text>
Hit me!
</Text>
<View>
{ConsolePanel}
</View>
</View>
);
}
}
how to resolve this error??
For the android emulator, Click on the emulator screen and Press Control + M ( Ctrl + M ), After open the dialog option select Remote JS Debugging. This will open a resource, http://localhost:8081/debugger-ui on localhost. From there, use the Chrome Developer tools JavaScript console to view console. log() .
You can access the developer menu by shaking your device or by selecting "Shake Gesture" inside the Hardware menu in the iOS Simulator. You can also use the ⌘D keyboard shortcut when your app is running in the iOS Simulator, or ⌘M when running in an Android emulator on macOS and Ctrl+M on Windows and Linux.
Take the following React code: function Element() { //Code is OK const variable = 1; console. log('1'); //Bug HERE while (true); console.
Remove this line:
var ConsolePanel = require('react-native-console-panel').displayWhenDev();
And also remove:
{ConsolePanel}
To log something to the console in React Native, simply do this:
console.log('Hi from React Native');
To see the console output, if you're on Mac OS or Linux, run this in a terminal window:
$ adb logcat | grep ReactNativeJS
If you're on Windows, see this StackOverflow question: How to easily view and filter Android's logcat in Windows?
Reading the logs is also documented in the Getting Started guide.
UPDATE: You can now run react-native log-ios
or react-native log-android
to see the logs in the console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With