कैसे प्राप्त करने के लिए मार्गों से दूसरे स्थान/समारोह में प्रतिक्रिया-रूटर-डोम v6?

0

सवाल

मैं कोशिश कर रहा हूँ प्रतिक्रिया रूटर V06, लेकिन एक समस्या का सामना जहां मैं कोशिश कर रहा है, यह नीचे इस तरह से लेकिन हर मार्गों और पृष्ठ रिक्त हैं ।

कोड:

// Main App Function
    const App = () => {
      return (
        <Router>
          <Fragment>
            <Navbar />
            <Routes>
              <Route index strict path="/" element={<Landing />} />
      **{/* Here I want to render paths from other function*/}**
              <Route element={<AppRoutes />} />
            </Routes>
          </Fragment>
        </Router>
      );
    };
    
    export default App;
    
    // In AppRoutes Function
    const AppRoutes = () => (
      <section className="container">
        <Routes>
          <Route strict path="login" element={<Login />} />
          <Route strict path="register" element={<Register />} />
          <Route path="*" element={<NotFound />} />
        </Routes>
      </section>
    );
    
    export default AppRoutes;
1

सबसे अच्छा जवाब

1

अनुप्रयोग में, घोषित Landing घटक होने के लिए सूचकांक पृष्ठ, और प्रस्तुत करना AppRoutes पर एक "/*" पथ की अनुमति देने के लिए मिलान उप-मार्गों.

एप्लिकेशन

<Router>
  <Navbar />
  <Routes>
    <Route index element={<Landing />} />
    <Route path="/*" element={<AppRoutes />} />
  </Routes>
</Router>

AppRoutes

const AppRoutes = () => (
  <section className="container">
    <Routes>
      <Route path="login" element={<Login />} />
      <Route path="register" element={<Register />} />
      <Route path="*" element={<NotFound />} />
    </Routes>
  </section>
);

Edit how-to-get-routes-from-other-location-function-in-react-router-dom-v6

2021-11-24 00:18:18

धन्यवाद, मुझे मूर्ख है, मैं यह समझ नहीं सकता छोटी सी समस्या है । यह महान काम है!
Gazi

@गाजी कोई चिंता नहीं है, क्या होता है हम सभी के लिए कभी कभी. भूल नहीं करने के लिए क्या करते हैं जब किसी को जवाब. चीयर्स!
Drew Reese

अन्य भाषाओं में

यह पृष्ठ अन्य भाषाओं में है

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

इस श्रेणी में लोकप्रिय

लोकप्रिय सवाल इस श्रेणी में