首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Redux <Connector>

Redux <Connector>
EN

Stack Overflow用户
提问于 2017-07-31 17:05:23
回答 2查看 244关注 0票数 0

如何使代码的这一部分与redux的新版本一起工作?这是使用reudx < 1.0版本的https://github.com/reactjs/redux/releases/tag/v1.0.0-rc,但现在Connectorreact-redux - undefined,它有可能使这个工作吗?

部分代码

代码语言:javascript
复制
import { Connector } from 'redux/react;

<Connector select={state => ({
                            center: state.map.get('mapInfo').get('center'),
                            zoom: state.map.get('mapInfo').get('zoom'),
                            markers: state.map.get('dataFiltered'),
                            visibleRowFirst: state.map.get('tableRowsInfo').get('visibleRowFirst'),
                            visibleRowLast: state.map.get('tableRowsInfo').get('visibleRowLast'),
                            maxVisibleRows: state.map.get('tableRowsInfo').get('maxVisibleRows'),
                            hoveredRowIndex: state.map.get('tableRowsInfo').get('hoveredRowIndex'),
                            openBallonIndex: state.map.get('openBalloonIndex')
                        })}>
                            {({dispatch, ...mapProps}) => (
                                <Map {...mapProps}
                                     {...bindActionCreators(mapActions, dispatch)}
                                />
                            )}
                        </Connector>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-07-31 17:12:10

尝尝这个

代码语言:javascript
复制
import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

class Map extends React.Component
{
//Your Map component
}

const mapStateToProps = (state = {}) => {
    return {
        center: state.map.get('mapInfo').get('center'),
                            zoom: state.map.get('mapInfo').get('zoom'),
                            markers: state.map.get('dataFiltered'),
                            visibleRowFirst: state.map.get('tableRowsInfo').get('visibleRowFirst'),
                            visibleRowLast: state.map.get('tableRowsInfo').get('visibleRowLast'),
                            maxVisibleRows: state.map.get('tableRowsInfo').get('maxVisibleRows'),
                            hoveredRowIndex: state.map.get('tableRowsInfo').get('hoveredRowIndex'),
                            openBallonIndex: state.map.get('openBalloonIndex')
    }
}

const mapDispatchToProps = (dispatch) => {
    return {
        actions: bindActionCreators(mapActions, dispatch)
    }
}

export default connect(mapStateToProps, mapDispatchToProps)(Map);
票数 3
EN

Stack Overflow用户

发布于 2017-07-31 17:11:28

我想这个包裹是换来的。试着进口。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45421622

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档