【发布时间】:2017-11-17 15:53:24
【问题描述】:
我正在使用 immutableJS、React/Redux 并且我有这张地图,我需要获取 actions 的值,所以它会像 -> allRetrospectivesMap -> id -> current_stage - > actions
我有这个代码,它可以工作,但它超级难看,有没有更好的方法?
class UserActionItems extends Component {
render() {
const { retrospectives } = this.props
const actions = flatten(
Object.keys(immutableHelpers.toJS(retrospectives))
.map(key => retrospectives.get(key))
.map(retro => immutableHelpers.toJS(retro.getIn(['current_stage', 'actions'])))
).value()
return (
<div>
<ActionsList
actions={actions[0]}
users={[]}
/>
</div>
)
}
}
const mapStateToProps = ({ allRetrospectivesMap }) => ({
retrospectives: allRetrospectivesMap
})
谢谢!!! :)
【问题讨论】:
标签: javascript reactjs dictionary redux immutable.js