• 로그인
  • 장바구니에 상품이 없습니다.

home2 게시판 React 게시판 리액트 라우터 link to 질문드려요

리액트 라우터 link to 질문드려요

4 글 보임 - 1 에서 4 까지 (총 4 중에서)
  • 글쓴이
  • #35498

    백지욱
    참가자

    import 'bootstrap/dist/css/bootstrap.min.css';
    import './App.css';
    import { useState } from 'react';
    import {Button, Navbar, Container, Nav} from 'react-bootstrap'
    import data from './data.js'
    import { Routes, Route, Link } from "react-router-dom"

    function App() {
     
    let [shoes] = useState(data)
    console.log(shoes)
    return (
    <div className='app'>
    <div>
    <Navbar bg="dark" variant="dark">
    <Container>
    <Navbar.Brand href="#home">Navbar</Navbar.Brand>
    <Nav className="me-auto">
    <Nav.Link href="#home">Home</Nav.Link>
    <Nav.Link href="#features">Features</Nav.Link>
    <Nav.Link href="#pricing">Pricing</Nav.Link>
    </Nav>
    </Container>
    </Navbar>

    <link to="/">홈</link>
    <link to="/detail">상세페이지</link>

    <Routes>
    <Route path='/' element={
    <>
    <div className='main-bg'></div>
    <div className="container">
    <div className="row">
    {
    shoes.map((a, i) => {
    return (
    <Card shoes={shoes[i]} i={i + 1}></Card>
    )
    })
    }
    </div>
    </div>
    </>
    } />
    <Route path='/detail' element={<dvi>상세페이지임</dvi>}/>
    <Route path='/about' element={<dvi>about페이지임</dvi>}/>
    <Route />
    <Route />
    </Routes>
     
    </div>
    </div>
    );
    }
     
    function Card(props) {
    return (
    <div className="col-md-4">

    <h4>{props.shoes.title}</h4>
    <p>{props.shoes.content}</p>
    <p>{props.shoes.price}</p>
    </div>
    )
    }

    export default App;

     

    이렇게 만들었는데......

    <link to="/">홈</link>
    <link to="/detail">상세페이지</link>

    이부분을 넣으면 흰색으로 화면이 나오고

    지우면 정상적으로 작동하네요 어떤 오류를 범햇을까요 ㅠㅠ

    강의따라 진행중입니다 ㅠㅠ

    #35500

    백지욱
    참가자

    react-jsx-dev-runtime.development.js:97 Warning: Each child in a list should have a unique "key" prop.

    Check the render method of App. See https://reactjs.org/link/warning-keys for more information.
    at Card (http://localhost:3000/static/js/bundle.js:209:64)
    at App (http://localhost:3000/static/js/bundle.js:43:64)
    at Router (http://localhost:3000/static/js/bundle.js:46264:15)
    at BrowserRouter (http://localhost:3000/static/js/bundle.js:45073:5)
    printWarning @ react-jsx-dev-runtime.development.js:97
    error @ react-jsx-dev-runtime.development.js:71
    validateExplicitKey @ react-jsx-dev-runtime.development.js:1076
    validateChildKeys @ react-jsx-dev-runtime.development.js:1103
    jsxWithValidation @ react-jsx-dev-runtime.development.js:1274
    App @ App.jsx:33
    renderWithHooks @ react-dom.development.js:16175
    mountIndeterminateComponent @ react-dom.development.js:20913
    beginWork @ react-dom.development.js:22416
    beginWork$1 @ react-dom.development.js:27381
    performUnitOfWork @ react-dom.development.js:26513
    workLoopSync @ react-dom.development.js:26422
    renderRootSync @ react-dom.development.js:26390
    performConcurrentWorkOnRoot @ react-dom.development.js:25694
    workLoop @ scheduler.development.js:266
    flushWork @ scheduler.development.js:239
    performWorkUntilDeadline @ scheduler.development.js:533
    2react-dom.development.js:18572 The above error occurred in the <link> component:

    at link
    at div
    at div
    at App (http://localhost:3000/static/js/bundle.js:43:64)
    at Router (http://localhost:3000/static/js/bundle.js:46264:15)
    at BrowserRouter (http://localhost:3000/static/js/bundle.js:45073:5)

    Consider adding an error boundary to your tree to customize error handling behavior.
    Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.
    logCapturedError @ react-dom.development.js:18572
    update.callback @ react-dom.development.js:18605
    callCallback @ react-dom.development.js:13122
    commitUpdateQueue @ react-dom.development.js:13143
    commitLayoutEffectOnFiber @ react-dom.development.js:23290
    commitLayoutMountEffects_complete @ react-dom.development.js:24578
    commitLayoutEffects_begin @ react-dom.development.js:24564
    commitLayoutEffects @ react-dom.development.js:24502
    commitRootImpl @ react-dom.development.js:26779
    commitRoot @ react-dom.development.js:26638
    finishConcurrentRender @ react-dom.development.js:25848
    performConcurrentWorkOnRoot @ react-dom.development.js:25765
    workLoop @ scheduler.development.js:266
    flushWork @ scheduler.development.js:239
    performWorkUntilDeadline @ scheduler.development.js:533
    react-dom.development.js:2939 Uncaught Error: link is a void element tag and must neither have children nor use dangerouslySetInnerHTML.
    at assertValidProps (react-dom.development.js:2939:1)
    at setInitialProperties (react-dom.development.js:9917:1)
    at finalizeInitialChildren (react-dom.development.js:10947:1)
    at completeWork (react-dom.development.js:19421:1)
    at completeUnitOfWork (react-dom.development.js:26552:1)
    at performUnitOfWork (react-dom.development.js:26524:1)
    at workLoopSync (react-dom.development.js:26422:1)
    at renderRootSync (react-dom.development.js:26390:1)
    at recoverFromConcurrentError (react-dom.development.js:25806:1)
    at performConcurrentWorkOnRoot (react-dom.development.js:25706:1)

     

    오류 내용입니다

    #35504

    백지욱
    참가자

    링크 투를 대문자를 안썻군요 ㅠㅠ

    #35505

    codingapple
    키 마스터

    <dvi>도 뭔가 이상합니다 

4 글 보임 - 1 에서 4 까지 (총 4 중에서)
  • 답변은 로그인 후 가능합니다.

About

현재 월 700명 신규수강중입니다.

  (09:00~20:00) 빠른 상담은 카톡 플러스친구 코딩애플 (링크)
  admin@codingapple.com
  이용약관, 개인정보처리방침
ⓒ Codingapple, 강의 예제, 영상 복제 금지
top

© Codingapple, All rights reserved. 슈퍼로켓 에듀케이션 / 서울특별시 강동구 고덕로 19길 30 / 사업자등록번호 : 212-26-14752 온라인 교육학원업 / 통신판매업신고번호 : 제 2017-서울강동-0002 호 / 개인정보관리자 : 박종흠