react-navigation / react-navigation/react-navigation

Screens with useLinkProps (using object) only work once within nested navigator (stack within bottom-tabs)

Aperta
#10,847 7 commenti 5 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug platform:ios platform:web repro provided
Lingua principale
TypeScript
Stelle
24.5k
Fork
5.1k
Merge medio
1g 5h
PR unite (30g)
18

Descrizione

Current behavior

I have a Stack.Navigator (native-stack but also tried using just stack) nested inside a Tab.Navigator.

Links actions (onPress), generated using useLinkProps (using object), only seems to work once.

This is in circumstances when you return to the previous screen with no re-render invoked (e.g. tab bar button or via back gesture)

Using a string path however, it works consistently

Example, this works repeatedly

const linkProps = useLinkProps({ to: '/b' });

This only works once

const linkProps = useLinkProps({
  to: {
    screen: 'StackNavigator',
    params: { screen: 'ScreenB' }
  }
});

Reproduction steps in repo snack:

  1. Use first button to navigate to Screen B (via screen props)
  2. Return to Screen A either via button in tab bar (or back gesture)
  3. Use same button to try to get to Screen B again, observe no navigation occurs

Video: https://user-images.githubusercontent.com/933275/190622422-0a187445-f276-41f7-9ce7-1bde3e130b0e.mov

I see a workaround where I switch exclusively to passing paths around, but this current behaviour seems like it might be a bug

Expected behavior

Expect navigation to occur when returning to previous screen and triggering the same action again

Reproduction

https://snack.expo.dev/@4lun/react-navigation---issue---uselinkprops-only-works-once-with-screen-props

Platform
  • Android
  • iOS
  • Web
  • Windows
  • MacOS
Packages
  • @react-navigation/​bottom-tabs
  • @react-navigation/​drawer
  • @react-navigation/​material-bottom-tabs
  • @react-navigation/​material-top-tabs
  • @react-navigation/​stack
  • @react-navigation/​native-stack
Environment
  • I've removed the packages that I don't use
package version
@react-navigation/native 6.0.12
@react-navigation/bottom-tabs 6.3.3
@react-navigation/native-stack 6.8.0
react-native-safe-area-context 4.3.1
react-native-screens ~3.15.0
react-native 0.69.5
expo ~46.0.0

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dalla riproduzione Snack collegata e dall’entry point useLinkProps, confrontando la navigazione basata su oggetti con il caso funzionante del percorso come stringa. Riproduci la sequenza di navigare a Screen B, tornare a Screen A e attivare nuovamente la stessa azione; il lavoro è completato quando la navigazione basata su oggetti ripetuta funziona su iOS e sul web.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
react-native, typescript
Ambito
frontend, mobile-dev
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.