我使用的是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
})
谢谢! :)