0

I want to re-render two tabs by setParams, it works if i dispatch to one tab, but dispatch to two tabs like code bellow doesn't work

const setParamsAction1 = NavigationActions.setParams({ params: { foo: 'bar' } }, key: 'a' });
const setParamsAction2 = NavigationActions.setParams({ params: { foo: 'bar' } }, key: 'b' });
this.props.navigation.dispatch(setParamsAction1);
this.props.navigation.dispatch(setParamsAction2);
TomSawyer
  • 3,711
  • 6
  • 44
  • 79

1 Answers1

0

I found out the easiest way is wrapping dispatch inside async function

async setNavParams(key) {
    await this.props.navigation.dispatch(NavigationActions.setParams({
        params: { foo: 'bar' },
          key: key,
        }))
}
TomSawyer
  • 3,711
  • 6
  • 44
  • 79