React-native: console.log("some text") does not get printed to Chrome console

Created on 7 Aug 2017  路  6Comments  路  Source: facebook/react-native

Is this a bug report?

yes

Have you read the Contributing Guidelines?

Yes

Environment

  1. react-native -v:
    react-native-cli: 2.0.1
    react-native: 0.47.1
  2. node -v:
    v7.10.0
  3. npm -v:
    4.2.0
  4. yarn --version:
    0.27.5

Then, specify:

  • Target Platform: iOS and Android

  • Development Operating System:
    macOS 10.12.6

  • Build tools:
    Chrome 60.0.3112.90

Steps to Reproduce

(Write your steps here:)

  1. Create a new react native project with react-native init NewProject
  2. Add a console print to index.ios.js and index.android.js in the render method, e.g.
...
export default class NewProject extends Component {

  render() {
    console.log("This should be printed in console!");
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit index.ios.js
        </Text>
        <Text style={styles.instructions}>
          Press Cmd+R to reload,{'\n'}
          Cmd+D or shake for dev menu
        </Text>
      </View>
    );
  }
}
...
  1. Run react-native run-ios from project root
  2. Enable Remote Debugging
  3. Open the console in Chrome
  4. Refresh app and nothing gets printed

Expected Behavior

In step 6 the text This should be printed in console! should have been printed to Chrome console

Actual Behavior

Nothing gets printed to console.
I think the issue may be related to the Chrome release since it was after an upgrade it stopped working.

Reproducible Demo

https://github.com/andidev/react-native-console-log-bug-example-project

Locked

Most helpful comment

No issue here, for some reason a console filter where applied. I how no idea how though. Closing this.

All 6 comments

No issue here, for some reason a console filter where applied. I how no idea how though. Closing this.

_-sigh-_

I ran into the exact same problem:

image

Me too all of a sudden

yeah strange same thing happened to me. thankfully i found this thread so I bothered checking the filters

having same problem, no filtering enabled

solution was to run debug mode (production clears console.log while minifying the code)

Was this page helpful?
0 / 5 - 0 ratings