Jim
Jim

Reputation: 2312

setDefaultOptions VS. static options VS. options in setRoot

Using Wix's react-native-navigation, what's the difference between setting layout options using these methodologies?

Navigation.setDefaultOptions({
  topBar: {
    background: {
      color: 'red'
    }
  }
});

vs.

static options(passProps) {
  return {
    topBar: {
      background: {
        color: 'red'
      }
    }
  };
}

vs.

Navigation.events().registerAppLaunchedListener(() => {
  Navigation.setRoot({
    root: {
      stack: {
        children: [{}],
        options: {
          topBar: {
            background: {
              color: 'red'
            }
          }
        }
      }
    }
  });
});

What are some reasons/cases/etc to define options statically inside a component, versus initializing a root with options? And what are the functional differences/what happens behind the scenes with these different ways?

Upvotes: 0

Views: 496

Answers (1)

angelos_lex
angelos_lex

Reputation: 1661

setDefaultOptions are default options that apply to all screens and all roots that will ever be created. static options is defined per screen and override defaultOptions but do not apply for all screens setRoot apply for this root only

Upvotes: 0

Related Questions