Skip to content

Commit

Permalink
Export YellowBox API
Browse files Browse the repository at this point in the history
Summary:
Allow end users to access the YellowBox API so that warnings can be properly ignored via the API first introduced in a974c14. Based on that API, you should be able to do the following:

```
import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings(['Warning: ...']);
```

However, if you actually try this today, it results in a broken import error.

Verified using an expo instance. First tried without the YellowBox import, observed a failure to import. Then I added the import statement, and observed no warning on my device.

```
import React from 'react';
import { StyleSheet, Text, View, YellowBox } from 'react-native';

YellowBox.ignoreWarnings(['hey']);

export default class App extends React.Component {
  render() {
    console.warn('hey!');
    return (
      <View style={styles.container}>
        <Text>Open up App.js to start working on your app!</Text>
        <Text>Changes you make will automatically reload.</Text>
        <Text>Shake your phone to open the developer menu.</Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});
```

[GENERAL] [ENHANCEMENT] [YellowBox] - Export YellowBox API so warnings can be ignored using a non-deprecated API.
Closes #16709

Differential Revision: D6254819

Pulled By: hramos

fbshipit-source-id: ff92f32e4dedfb01f6902f54fabc62eb64468554
  • Loading branch information
wli authored and facebook-github-bot committed Nov 7, 2017
1 parent 2be3ae1 commit 26038f5
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Libraries/react-native/react-native-implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const ReactNative = {
get unstable_batchedUpdates() { return require('ReactNative').unstable_batchedUpdates; },
get Vibration() { return require('Vibration'); },
get VibrationIOS() { return require('VibrationIOS'); },
get YellowBox() { return require('YellowBox'); },

// Plugins
get DeviceEventEmitter() { return require('RCTDeviceEventEmitter'); },
Expand Down

0 comments on commit 26038f5

Please sign in to comment.