![](/img/trans.png)
[英]How could i pass a value from a child component to parent, when i have multiple child components?
[英]I receive an undefined value when I pass the value of a variable through props from a parent component to a child component
我在 app.js 中創建了一個變量 pointsFilter 並通過道具我將值發送到一個子組件,在這種情況下,該組件是 Map 但是當我想提取值時我得到未定義並且當我在應用程序中執行 console.log 我得到該值,但是當我在 map.js 中執行相同操作時,我得到未定義
應用程序.js
const [pointsFilter, setPointsFilter] = useState(true)
<Map onLongPress={handleLongPress} puntos={puntos} poinstFilter={pointsFilter} />
map.js
export default ({ onLongPress, puntos, pointsFilter }) => {
console.log(pointsFilter)
return (
<Mapview style={styles.map} onLongPress={onLongPress} >
{pointsFilter && puntos.map(x => <Marker coordinate={x.coordinate} title={x.name} key={x.name} />)}
</Mapview>
)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.