小编Gui*_*ghi的帖子

如何从输入组件获取值(研究目的)?

我的问题是我正在尝试处理输入的值,用户通过 API 调用定义他想要的输入。

这是我获取值的地方:

 const handleClick = buttonTitle => async () => {
    await renderField(buttonTitle).then(response => {               
      navigation.navigate('FormScreen', {
        collectionKey: buttonTitle.slice(7),
        paramKey: JSON.stringify(response),
      });     
  });
  };
Run Code Online (Sandbox Code Playgroud)

渲染字段是一个 API 调用,它返回我{"message": [{"_id": "618e4c23db08f70b719f3655", "author": "adicionarei posteriormente", "ceatedAt": "2021-11-12 08:12:32", "field": "abc", "fieldtype": "Text"}, {"_id": "618e4c9ddb08f70b719fae37", "author": "adicionarei posteriormente", "ceatedAt": "2021-11-12 08:14:35", "field": "Animal", "fieldtype": "Text"}]}

然后我有我的 Form 组件,我在其中获取一些需要的组件并向用户显示:

const FormScreen = ({route, navigation}) => {
  return (
    <Container>
      <InputBody route={route.params.paramKey} navigation={navigation} />
    </Container>
    // => handle submit Input it in here …
Run Code Online (Sandbox Code Playgroud)

javascript function jsx react-native

12
推荐指数
1
解决办法
318
查看次数

标签 统计

function ×1

javascript ×1

jsx ×1

react-native ×1