通用状态管理功能流类型反应

时间:2018-06-20 11:27:33

标签: reactjs react-native flowtype

我对如何制作通用状态更新程序有疑问

type State = {
    name: string,
    age: number,
    contactInfo: ContactInfo
}

以及在我的组件中

onChangeField = (field: $Keys<State>) => (value: $ElementType<State, field>) => {
    this.setState({ [field]: value });
}

我遇到错误,因为字符串文字“ contactInfo”是一个值,所以不能使用文字“ contactInfo”作为类型。

您可以签入尝试流程游乐场here

0 个答案:

没有答案
相关问题