Replies: 2 comments 4 replies
-
I thought some react native apis must for sure listen to config changes, so I can implement that in a similar way. Indeed the and being called in so I cant do that for my native module Can we make config changes accessible to modules? |
Beta Was this translation helpful? Give feedback.
-
Have you considered asking users to edit the override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
MyCustomLibrary.dispatchOnConfigurationChanged(newConfig)
} That will allow to listen for config changes on the library. Also you could use an expo config-plugin to achieve this same result without having to ask the user to manipulate their file at all. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I would like to be able to listen to config changes to the main activity in android in a native module.
As far as I know I am able to listen to activity config changes by overriding the activity's
onConfigurationChanged
method. However, since that is part of the app and not my native module then I cant edit this part.Library Users can manually emit that change (using intents as an example) as done in
react-native-locale-listener
, but it is inconvenient.I see that
ReactActivity
already overrides this method for some internal use cases I believe:https://github.com/facebook/react-native/blob/4076dbfc8651fcd193b886bf63b23728fad466d7/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java#L141-L145
I think it would be really convenient if somehow this listener can propagate the event to library authors.
Example use case
Listen to app locale changes which results in a
onConfigurationChanged
on the activityLet me know your thoughts
Beta Was this translation helpful? Give feedback.
All reactions