RootRagContext

RootTags are useful for when an app renders multiple React Native root views and you need to handle native API calls differently depending on the surface.


RESETRUNFULL
import { RootTagContext } from 'react-native';import NativeAnalytics from 'native-analytics';import NativeNavigation from 'native-navigation';function ScreenA() {
  const rootTag = useContext(RootTagContext);
  const updateTitle = (title) => { NativeNavigation.setTitle(rootTag, title);};
  const handleOneEvent = () => {
    NativeAnalytics.logEvent(rootTag, 'one_event');
  };  // ...}class ScreenB extends React.Component {
  static contextType: typeof RootTagContext = RootTagContext;
  updateTitle(title) {
    NativeNavigation.setTitle(this.context, title);
  }
  handleOneEvent() {
    NativeAnalytics.logEvent(this.context, 'one_event');
  }  // ...}