使用 Ramda 更新 mapStateToProps
Update mapStateToProps with Ramda
项目中使用了以下条目,很明显state
参数经常使用
const props = state => ({
name: getUserName(state),
role: getUserRole(state),
region: getUserRegion(state),
});
如何使用 ramda 更新它?
您可以使用 R.applySpec:
const mapStateToProps = R.applySpec({
name: getUserName,
role: getUserRole,
region: getUserRegion,
});
项目中使用了以下条目,很明显state
参数经常使用
const props = state => ({
name: getUserName(state),
role: getUserRole(state),
region: getUserRegion(state),
});
如何使用 ramda 更新它?
您可以使用 R.applySpec:
const mapStateToProps = R.applySpec({
name: getUserName,
role: getUserRole,
region: getUserRegion,
});