React native - 在 this.props 之后返回一个字符串

React native - Returning a string after this.props

我是 React native 的完全初学者,javascript 总的来说。 我需要 return 组件内两个道具的组合。 我有一个 JSON 格式的数据道具和一个代表我应该从数据中 return 的字符串道具。

_displayText = (id) => {
   var text = this.props.selectedRows[id].label
   const {data} = this.props
   return(......)
}

所以这里的文本变量包含类似“pv_id_workstream.label”的内容。 是否可以 return 类似数据的东西。(文本的结果)?

return data[text] 可能就是您要找的。