하나의 React Route Component에서 다른 React Route 구성 요소로 객체를 전송하는 방법을 찾을 수 없습니다.React Routes 4 사이의 소품 전달 방법
const App =() => (
<Router>
<div>
<Route exact path="/" component={Home} />
<Route path="/sections/:id"
component={Section} />
</div>
</Router>
)
과 같은 구성 요소 Home
과 함께 : 예를 들어 는이 같은 컨테이너 라우터가
const Home =() => {
const Sections = tilesData.map((section, index) => (
<div>
<img src={section.img} height="200" /><br/>
<Link to={`/sections/'${section.id}`} >Details for {section.author}</Link>
<hr/>
</div>
))
return(
<div>
{Sections}
</div>
)
}
을하고 난 다음 경로 <Link>
로 클릭하면 선택한 개체를 전달하는 방법을 \ = 이해가 안 돼요. 여기에 예를 들어 구성 요소입니다 : 여기
const Section = (props) => {
return(
<div>
Section {props.title}
<img src={props.img} />
</div>
)
}
코드 예제입니다
https://codesandbox.io/s/Mv037AE3
'react-redux'를 사용하고 상점의 데이터를 가지고 한 구성 요소에서 다른 구성 요소로 전달하는 대신 ID를 사용하여 상점의 데이터에 액세스 할 수 있습니다. 이러한 방식으로 데이터는 중앙 집중식으로 배치되어 모든 구성 요소에 액세스 할 수 있습니다. – Aruna
예 .. 아마 당신 말이 맞아요 & 나는'react-redux'를 더 잘 지키려고합니다. 감사합니다!) – Jamland