From 26038f50bb003eec3770e2b66d428fbb739f1ce2 Mon Sep 17 00:00:00 2001 From: William Li Date: Mon, 6 Nov 2017 17:26:39 -0800 Subject: [PATCH] Export YellowBox API Summary: Allow end users to access the YellowBox API so that warnings can be properly ignored via the API first introduced in a974c140db605ecbdf8d3faa7a079b7e2dcebb09. 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 ( Open up App.js to start working on your app! Changes you make will automatically reload. Shake your phone to open the developer menu. ); } } 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 https://github.com/facebook/react-native/pull/16709 Differential Revision: D6254819 Pulled By: hramos fbshipit-source-id: ff92f32e4dedfb01f6902f54fabc62eb64468554 --- Libraries/react-native/react-native-implementation.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Libraries/react-native/react-native-implementation.js b/Libraries/react-native/react-native-implementation.js index 88cd864c1..577a896cd 100644 --- a/Libraries/react-native/react-native-implementation.js +++ b/Libraries/react-native/react-native-implementation.js @@ -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'); },