0
我是新來的反應,我試圖分開組件。以下示例容器或組件?對於我來說都是組件,但我不確定,因爲他們有鏈接標記和路由標記。反應組分vs容器
Page.jsx
<main role="application">
<Switch>
{/* Home */}
<Route path="/" exact component={Home} />
{/* Profile */}
<Route path="/user/:id" exact component={Profile} />
{/* Error 404 */}
<Route component={Error404} />
</Switch>
</main>
User.jsx:
function User(props) {
return (
<div id={`user-${props.id}`}>
<Link to={`/user/${props.id}`}>
{props.name}
</Link>
<p>{props.email}</p>
</div>
);
}
User.propTypes = {
id: PropTypes.number.isRequired,
name: PropTypes.string.isRequired,
email: PropTypes.string.isRequired,
};
export default User;
只是作爲一個附錄,您對「組件」或「容器」的引用映射到這些「表示」和「容器」組件。 –