React Navigation V2: Difference between navigation.push and navigation.navigate

后端 未结 3 1873
有刺的猬
有刺的猬 2020-12-06 04:41

I\'m new to React Native and I\'m currently studying the React Native Navigation Docs. I was wondering: What is the difference between navigation.push() and

3条回答
  •  情书的邮戳
    2020-12-06 05:35

    According to the last blog post here: for v1:

    navigate(routeName) and push(routeName) were very similar: every time you called navigate(routeName) it would push a new route to the stack.

    for v2:

    Now navigate(routeName) will first try to find an existing instance of the route and jump to that if it exists, otherwise it will push the route to the stack.

    navigate > go to instance of page if exist or push a new instance

    push > push a new instance even if one exist already

提交回复
热议问题