Skip to content

Can I update state in setBackgroundMessageHandler() ? #5089

Answered by mikehardy
GaylordP asked this question in Q&A
Discussion options

You must be logged in to vote

Sorry for the delay in response - and as someone that speaks English natively but only recently learned Spanish and knows the difficulty of a non-native language, your English is fantastic. Worth saying

When we say you should not update state we mean that you should not update any React component state, we mention that because in the background and quit states where setBackgroundMessageHandler runs, there is no active Android Activity, and no components are mounted.

I think it is valid to update other types of state (for example redux or ReSub or AsyncStorage etc) and if you integrate with a notification package like react-native-push-notification or Notifee.app it may make sense to post …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by andersonaddo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants