我需要将道具从包装器传递到子组件
具有这样的结构:
CabinetBlockContainer.jsx
smallChild.jsx
现在,我的 smallChild.jsx 如下:
struct DataModel: Codable {
let meta: Meta?
let data: [Datum]?
}
struct Datum: Codable {
let type, subType, name, detailedName: String?
let id: String?
let datumSelf: SelfClass?
let iataCode: String?
let address: Address?
enum CodingKeys: String, CodingKey {
case type, subType, name, detailedName, id
case datumSelf = "self"
case iataCode, address
}
}
struct Address: Codable {
let cityName, countryName: String?
}
struct SelfClass: Codable {
let href: String?
let methods: [String]?
}
struct Meta: Codable {
let count: Int?
let links: Links?
}
struct Links: Codable {
let linksSelf: String?
enum CodingKeys: String, CodingKey {
case linksSelf = "self"
}
}
和我的 容器如下:
return (
<CabinetBlockContainer>
<div className={props.className}>
<Typography variant="h6" color="primary">
{props.title}
</Typography>
<Typography variant="caption">{props.subtitle}</Typography>
</div>
<BalanceSmallBlock balance="1254.51" needIcon={props.needIcon} />
</CabinetBlockContainer>
);
我的积木样式很多,这就是为什么我创建了包装器( CabinetBlockContainer )。我需要将道具从CabinetBlockContainer传递到其子组件。我真的不知道这是最佳做法,但看起来很正常。
我试图在文档中找到如何传递像这样的道具,但是有任何解决方案。