reactjs - 如何在反应中使用道具将数据获取到父组件?
问题描述
主页.js
import React from 'react';
import {Overlay} from "./MainOverlay";
const MainPage = () => {
return (
<View style={[styles.center, {top: 50}]}>
........some code.........
<Overlay data1={somedata1},data2={somedata2}/> //passing some data as props, I need some data to be returned back here
........some code.........
</View>
);
}
export default MainPage;
MainOverlay.js
const Overlay = (props) => {
return(
.......some code.......
<View>{props.data1}</View>
<View>{props.data2}</View>
<InputText/> //for user to enter some data
<Button title="save" onClick={}/> //here i need to pass the input text data "x" to Mainpage.js, is there a way to send data to mainpage.js?
);
}
export Overlay;
我是 react native 的初学者,所以我不知道它是如何工作的。
当我按下叠加层中的保存按钮时,我需要将数据从叠加层发送到主页,这就是我的问题
解决方案
推荐阅读
- javascript - 如何使用 Flask 丑化 ES6 javascript?
- gradle - Kotlin js 没有从 gradle 实现中获取依赖项(构建文件中的 npm 部分
- python - Python 和多处理
- c++ - 特征复数矩阵向量乘法
- odata - Azure 搜索 - GeographyPoint 的查询集合
- tfs - 此计算机或其他 JetBrains WebStorm 上已为您存在工作区
- python - 如何在不影响主图比例的情况下绘制平面?
- python - Python 中的数据可用性图表
- java - Android - 可以使用两个词作为包名吗?
- c - 中缀到后缀循环