美文网首页
【React Native】中使用Redux 以后ref 组件出

【React Native】中使用Redux 以后ref 组件出

作者: 花弄笑 | 来源:发表于2018-04-16 15:13 被阅读0次

出现这个问题的原因是:connect会把组件再包一层,让我去了解一下reduxconnectwithRef

查看 redux 源码学习笔记 :
react-redux之connect方法解析
react-redux源码学习笔记

解决代码

export default connect(state => ({
        state: state
    }),
    (dispatch) => ({
    }), null, {withRef: true}
)(Component);

使用

 this.listView && this.listView.getWrappedInstance().scrollTo({y:0});

相关文章

网友评论

      本文标题:【React Native】中使用Redux 以后ref 组件出

      本文链接:https://www.haomeiwen.com/subject/ahlekftx.html