How to pass properties from native(Android) to React Native?
You can pass properties down to the React Native app by providing a custom implementation of
ReactActivityDelegatein your main activity. This implementation should override
getLaunchOptionsto return a
Bundlewith the desired properties.
The key part is a custom implementation of
I always like to show you code first before dive deep the implementation.
The guide says how to set app properties via a react root view, but it didn't mention how you can get it.
I fulfilled that part in my custom react activity delegate snippets:
ReactRootViewprovides a read-write property
appPropertiesis set, the React Native app is re-rendered with new properties. The update is only performed when the new updated properties differ from the previous ones.
I used it in my custom LaunchAppAdManager.java and update the app properties in the Ads status callback.
React Native App.tsx
based on the launch ads state, React app decides show Home component or Interstitial(I used a full screen gif as the loading spinner).