react-navigation / react-navigation/react-navigation.github.io

Documentation for web use is confusing and/or incomplete

Aperta
#531 0 commenti 7 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
JavaScript
Stelle
324
Fork
2k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I began exploring bringing my RN project to the web via react-native-web and quickly hit a stumbling block with react-navigation due to the confusing or incomplete documentation about web usage. I'm referring to the documentation here:

https://reactnavigation.org/docs/en/web-support.html

Specifically the following are/were points of confusion

  1. The "with react native web" section only mentions using expo. React-native-web seems to be the de-facto mechanism to bring RN projects to web in the community and I would guess that a lot (or most) projects don't use non-ejected expo. How does react navigation web support relate to react-native-web in general outside of the context of expo?
  2. The "with standard web tools" section isn't really clear about what "standard web tools" means in this context. It seems to refer to using react-native-web or a plain web browser with a bundler like webpack?
  3. The package names are confusing and I couldn't find any clarification. There's react-navigation @react-navigation/core, @react-navigation/web and a bunch of others on NPM with no indication that I could find of what the difference between them is. The @react-navigation packages seem to be lower/older versions but are recommended for web use in the docs. Which package is for which usage and which packages are old/deprecated?
  4. How does using the packages in the example @react-navigation/core and @react-navigation/web work alongside "normal" react-navigation in a react-native-web project? This appears to be missing entirely from the docs and I had to hack/find a solution across a lot of different issues in a bunch of repos.
  5. Are there TS definitions for the @react-navigation packages?

Here's how I've ended up configuring my navigator but honestly I have no idea if this is the best/correct/compatible way to do it with react-native-web:

import { createSwitchNavigator } from "@react-navigation/core"
import { createAppContainer } from "react-navigation"
// import { createStackNavigator } from "react-navigation-stack"
import { createBrowserApp } from "@react-navigation/web"

import AuthScreen from "../screens/AuthScreen"
import HomeScreen from "../screens/HomeScreen"
import AuthLoadingScreen from "../screens/AuthLoadingScreen"
import Main from "../../Main"
import { Platform } from "react-native"

const AppStack = createSwitchNavigator({ Home: Main }, { headerMode: "none" })
const AuthStack = createSwitchNavigator({ SignIn: AuthScreen }, { headerMode: "none" })

let appNavigator = createAppContainer(
    createSwitchNavigator(
        {
            AuthLoading: AuthLoadingScreen,
            App: AppStack,
            Auth: AuthStack
        },
        {
            initialRouteName: "AuthLoading"
        }
    )
)

if (Platform.OS == "web") {
    appNavigator = createBrowserApp(
        createSwitchNavigator(
            {
                AuthLoading: AuthLoadingScreen,
                App: AppStack,
                Auth: AuthStack
            },
            {
                initialRouteName: "AuthLoading"
            }
        )
    )
}
export default appNavigator

Some clarification on if this is a good/acceptable approach would be appreciated. Once I figure out the answers to these questions myself perhaps I'll be able to submit a documentation PR to help others avoid this confusion.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

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 documentazione sul supporto web disponibile all’indirizzo reactnavigation.org/docs/en/web-support.html e rivedi gli esempi dei package referenziati nell’issue. Chiarisci in che modo react-native-web è correlato a Expo e agli strumenti web standard, distingui i package di navigazione e il supporto per TypeScript, e documenta la configurazione consigliata. Il lavoro è completo quando le domande elencate hanno ricevuto risposta senza richiedere ai lettori di cercare in altri repository.

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

Valutazione

Stack tecnologico
javascript, react, react-native
Ambito
documentation, mobile-dev, web-dev
Tipo di issue
Documentazione
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.