![](/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.