Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use hoist-non-react-methods instead of hoist-non-react-statics #270

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"webpack": "^1.11.0"
},
"dependencies": {
"hoist-non-react-statics": "^1.0.3",
"hoist-non-react-methods": "^1.0.2",
"invariant": "^2.0.0"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/components/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const storeShape = require('../utils/storeShape')
const shallowEqual = require('../utils/shallowEqual')
const isPlainObject = require('../utils/isPlainObject')
const wrapActionCreators = require('../utils/wrapActionCreators')
const hoistStatics = require('hoist-non-react-statics')
const invariant = require('invariant')
import hoistMethods from 'hoist-non-react-methods'

const defaultMapStateToProps = state => ({}) // eslint-disable-line no-unused-vars
const defaultMapDispatchToProps = dispatch => ({ dispatch })
Expand Down Expand Up @@ -270,7 +270,7 @@ function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {})
}
}

return hoistStatics(Connect, WrappedComponent)
return hoistMethods(Connect, WrappedComponent, w => w.getWrappedInstance())
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/components/connect.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ describe('React', () => {
)
})

it('should return the instance of the wrapped component for use in calling child methods', () => {
it('should return the instance of the wrapped component with its child custom methods', () => {
const store = createStore(() => ({}))

const someData = {
Expand Down Expand Up @@ -1295,7 +1295,7 @@ describe('React', () => {

const decorated = TestUtils.findRenderedComponentWithType(tree, Decorated)

expect(() => decorated.someInstanceMethod()).toThrow()
expect(decorated.someInstanceMethod()).toBe(someData)
expect(decorated.getWrappedInstance().someInstanceMethod()).toBe(someData)
expect(decorated.refs.wrappedInstance.someInstanceMethod()).toBe(someData)
})
Expand Down