-
Notifications
You must be signed in to change notification settings - Fork 24.7k
[Android][0.22.2] Possible Unhandled Promise Rejection after reopening app from minimized/background state #6700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is there anything which re-renders the component in which you've the statusbar? e.g. - some event which updates state in parent component. |
Do you use AppState and Also the warning should not happen in 0.23.0-rc1 as I've changed the implementation to be smarter and not update the status bar values if they didn't change. |
@satya164 , yes. The snippet is my BaseContainer which is used by Home screen that updates a lot. I'm also using AppState in my Home screen. |
OS: Ubuntu 15.10 I have this issue with the emulator Geny motions. When I'm saving the file it will say "Hot loading..." and give me the same error below. I would like to give a log, but no idea where the log is saved from either genymotion or react-native. Any specific code this happens? no, it happens with any code. |
I am having the same issue, but for me it happens only on device, not on emulator (I am using the new standard emulator from build tools 25.1.1 rather than GenyMotion emulator, so that may be related). Whenever I make a change in my editor and cause a Hot Reload on device (Samsung Galaxy S7, haven't tested on other devices yet), I get the Promise Rejection warning. Output from logcat is:
|
I saw this warning and in my case it was because I was calling |
I got the same warning occasional on startup. (react-native: 0.28.0, react: 15.0.0, Android):
I found the rejection in the native implementation: @ReactMethod
public void setHidden(final boolean hidden, final Promise res) {
final Activity activity = getCurrentActivity();
if (activity == null) {
// res.reject("E_NO_ACTIVITY", "Tried to change the status bar while not attached to an Activity");
res.reject(ERROR_NO_ACTIVITY, ERROR_NO_ACTIVITY_MESSAGE);
return;
}
// ...
} However, the rejection is not handled in the JavaScript implementation: // react-native/Libraries/Components/StatusBar/StatusBar.js
const StatusBarManager = require('NativeModules').StatusBarManager;
setHidden(hidden: boolean, animation?: StatusBarAnimation) {
animation = animation || 'none';
StatusBar._defaultProps.hidden.value = hidden;
if (Platform.OS === 'ios') {
StatusBarManager.setHidden(hidden, animation);
} else if (Platform.OS === 'android') {
StatusBarManager.setHidden(hidden);
}
}, Is there any way to pend the Sorry for my broken English. |
I think this happens methods on statusbar before react-native is attached to an activity. The best way to avoid this is either to use the component or call methods in componentDidMount of your main component. We should probably improve the error message to make this less confusing and maybe catch the promise to avoid the unhandled promise rejection. |
It seems that componentDidMount of the main component may happen before react-native is attached to an activity. class RNTest extends Component {
componentDidMount() {
StatusBar.setHidden(true);
}
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
</View>
);
}
}
// ...
AppRegistry.registerComponent('RNTest', () => RNTest); |
+1, v0.32 I get the same WARNING message on device when the app is starting and then make it background by press HOME key. After switch to the app, the StatusBar has no effect and I'm running to the same issue. Why there should be a WARNING messege? If it can't be setHidden, so it is. I think taking away the reject message makes sense |
+1, v0.33 same problem as @smallpath |
+1 RN.0.34.0.RC.0 |
+1RN.0.34.0 |
+1 RN 0.34.1 |
hey guys, how did you work around this issue? |
#10421 should fix this, the warning will be moved to a native log. |
Fresh 0.36 too. Is it possible that it is related to router-flux somehow? Or you don't use it? |
+1 RN 0.36.1 |
This also happens to me and when I reopen the app the status bar is permanently hidden :/ |
Getting this with RN 0.37 (Android, Windows) on emulator (have not tried an actual device) when I return to the app from a background state, but only when I exit the app with the Android hardware back button. All I'm doing is:
and:
|
+1 RN 0.37 |
+1 RN 0.38 |
+1 RN 0.38 I don't get the orange error message, but my translucent status bar loses all of it's styling. I'm using the component rather than the API. This issue only occurs sometimes, specifically when:
|
same here |
Can I connect a Node API with a Exponent's project on localhost and watch the result on my iPad? I'm trying but show me the error: "Possible Unhandled Promise Rejection (id:0) Network request failed" |
This issue has been open for a year. My understanding is that the issue that was originally reported was addressed in 0.23. Afterwards, other similar but unrelated issues have been reported on this same thread by different people. I don't think we'll be able to troubleshoot every single issue individually in this thread. I am going to go ahead and close this issue as resolved. If you believe this is done in error, please open a new issue and make sure to fill out the template when doing so. Thanks! |
React Native Version: 0.22.2
Platform: Android
System: Ubuntu 15.04
Device: Samsung Note 3 (5.0)
Hi guys, after upgrading from 0.21 to 0.22.2, I'm experiencing the warning below every time I reopen my app from minimized/background state.
'Possible Unhandled Promise Rejection (id: 0): Tried to change the status bar while not attached to an Activity'
But when I remove the StatusBar component from my view, the warning goes away (obviously).
This is my snippet:
The text was updated successfully, but these errors were encountered: