【发布时间】:2021-01-12 03:00:16
【问题描述】:
我有一个这样的列表:
const form = [
<Input title="What is your age?" onSubmit={} />, // this onSubmit sets age
<MultipleChoice title="What is the weather today?" onSubmit={} />, // this onSubmit sets weather
<Input title="What is the brand of your rain coat?" onSubmit={} /> // this onSubmit sets rainCoatBrand
]
注意:上面的列表没有在 React 组件中定义。我也有这样的店:
age: number;
weather: string;
rainCoatBrand: string;
对于form 中的每个元素,如何设置onSubmit 方法以使用我想要的值更新存储?谢谢!
【问题讨论】:
标签: reactjs typescript redux