Skip to content

Commit

Permalink
fix(rn): react native react-redux 版本太低 close #5335
Browse files Browse the repository at this point in the history
  • Loading branch information
Pines-Cheng committed Jan 20, 2020
1 parent 11375dc commit e92c019
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/taro-redux-rn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
"regenerator-runtime": "^0.12.1"
},
"dependencies": {
"react-redux": "^5.0.7"
"react-redux": "^7.1.0"
}
}
43 changes: 36 additions & 7 deletions packages/taro-redux-rn/src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { Provider, connect as originConnect, connectAdvanced } from 'react-redux'
import {
Provider, connect as originConnect, connectAdvanced,
batch,
useSelector,
useDispatch,
useStore,
useActions,
shallowEqual
} from 'react-redux'
import React from 'react'

function connect (mapStateToProps = null, mapDispatchToProps = null, mergeProps = null, options = {}) {

options.withRef = true
let connectAdvanced = originConnect(mapStateToProps, mapDispatchToProps, mergeProps, options)
let connectAdvanced = originConnect(mapStateToProps, mapDispatchToProps,
mergeProps, options)

return (WrappedComponent) => {
let Connect = connectAdvanced(WrappedComponent)
Expand All @@ -27,12 +35,13 @@ function connect (mapStateToProps = null, mapDispatchToProps = null, mergeProps
* @returns {*}
*/
getWrappedInstance () {
return this.connectRef.current && this.connectRef.current.getWrappedInstance()
return this.connectRef.current &&
this.connectRef.current.getWrappedInstance()
}

render () {
return (
<Connect ref={this.connectRef} {...this.props}/>
<Connect ref={this.connectRef} {...this.props} />
)
}
}
Expand All @@ -41,5 +50,25 @@ function connect (mapStateToProps = null, mapDispatchToProps = null, mergeProps
}
}

export { Provider, connect, connectAdvanced }
export default {Provider, connect, connectAdvanced}
export {
Provider,
connect,
connectAdvanced,
batch,
useSelector,
useDispatch,
useStore,
useActions,
shallowEqual
}
export default {
Provider,
connect,
connectAdvanced,
batch,
useSelector,
useDispatch,
useStore,
useActions,
shallowEqual
}

0 comments on commit e92c019

Please sign in to comment.