codedamn

Introduction

Created by Codedamn about a year ago

0

No description provided

10 Comments

    1

    Fails to compile Hi, My code is the same but my app doesnt run and says :

    src\App.js
      Line 8:53:  'home' is not defined   no-undef
      Line 9:58:  'about' is not defined  no-undef
    

    which makes sense since we didnt use it but it does run for you… my full code is

    import React from 'react'
    import { BrowserRouter as Router, Switch, Route, Link } from 'react-router-dom'
    
    function App() {
       return (
          <Router>
             <Switch>
                <Route path='/' exact={true} component={home} />
                <Route path='/about' exact={true} component={about} />
             </Switch>
          </Router>
       )
    }
    export default App
    

    \

    @ksenei

    Ksenia Brag

    @ksenei

    0

    Hacking <Switch> When you mentioned that it returns the first fulfilled requirement, I thought, well, why not just put “/” last then?

    This also works:

           <Switch>

                  <Route path="/About" component={About} />

                  <Route path="/" component={Home} />

            </Switch>

    @cwlind

    Clark Lind

    @cwlind

    1

    BrowserRouter is not working don't know why

    0

    This section should be updated becuase react router currently doesn't support browser router and other things in V6

    @coderpatel

    Mithlesh Kumar

    @coderpatel

    2

    For anyone seeing issues trying the hello-world example... you can no longer put in the content in between the opening and closing <react> tags. The content you want is now passed in as jsx through the "element" prop.

    So it's now <Route path="whatever" element={your JSX}/>

    And you can no longer do: <Route path="whatever">Your JSX</Route>

    2

    If you are coding currently, the explained code in this video won't work You can check this for references

    import React, { useState } from 'react' import { BrowserRouter, Route, Link, Routes } from 'react-router-dom'

    //In this .jsx we have routing

    function App() { return <BrowserRouter> <div> <nav> <ul> <li> <Link to="/about">About</Link> </li> <li><Link to="/">Home</Link></li> </ul> </nav> <Routes> <Route path="/about" element={<h1>Router Home</h1>} /> </Routes> </div> </BrowserRouter> }

    export default App

    @hardick

    Hardick Chatterjee

    @hardick

    3

    Please update this course Codedamn.

    @nileshu

    Nilesh Unde

    @nileshu

    0

    Ritwik Raj Singha few seconds ago In the updated version of React, the syntax has changed. If you're experiencing any difficulties with this tutorial, you can use the following syntax:

    import React from 'react'; import '../App.css'; import { BrowserRouter, Route, Routes } from 'react-router-dom';

    export default function ReactRouter() { return (

    <div> <BrowserRouter> <Routes> <Route path="/hello-world" element={<h1>I am on the Hello World route</h1>} /> </Routes> </BrowserRouter> <h2>I am just an h2</h2> </div> ); }
    @ritwikrajsingh

    Ritwik Raj Singh

    @ritwikrajsingh

    0

    plz update the course it is so costly and still things are not updated

    @ayushblock

    Ayush Singh

    @ayushblock

    1

    //Updated Syntax For Route Usage.

    import React from 'react'; import { BrowserRouter, Route, Routes,Link } from 'react-router-dom';

    export default function ReactRouter() { return (

    <div> <BrowserRouter> <h3>Navbar</h3> <nav> <ul> <li><Link to="/hell-world">Go to Hell</Link></li> <li><Link to="/">Go Home</Link></li> <li><Link to="/hello-world">Go to Hello World</Link></li> </ul> </nav> <h3>Portal Below</h3> <hr /> <Routes> <Route path="/hello-world" element={<h1 style={{background: 'lightgreen'}}>I am on the Hello World route</h1>} /> <Route path="/" element={<h1 style={{background: 'lightblue'}}>I am on the Home route</h1>} /> <Route path="/hell-world" element={<h1 style={{background: 'red'}}>I am on the Hell World route</h1>} /> </Routes>
    </BrowserRouter>
    <hr />
    <h2>I am just an h2</h2>
    
    </div> ); }
    @pranshubasak

    Pranshu Basak

    @pranshubasak

Your comment