react-navigation / react-navigation/react-navigation
Screens with useLinkProps (using object) only work once within nested navigator (stack within bottom-tabs)
Nessuno ha ancora preso questa issue.
- 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:
- Use first button to navigate to Screen B (via screen props)
- Return to Screen A either via button in tab bar (or back gesture)
- 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
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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- 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