Skip to content

Commit

Permalink
should warn if pure option is present
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbrainard committed Oct 7, 2019
1 parent aa0bdc6 commit 32ff72b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/components/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ function connectFactory(defaults = {}, options = {}) {
'However, this custom Request would only be used in the default buildRequest.'
)

warning(options.pure === undefined, '`pure` option is no longer supported')

return connect(map, defaults, finalOptions)
}

Expand Down
20 changes: 19 additions & 1 deletion test/components/connect.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,6 @@ describe('React', () => {
expect(invocationCount).toEqual(2)
})

// TODO: clean up test
it('should deprecate mapPropsToRequestsToProps with context', () => {
let consoleSpy = expect.spyOn(console, 'error')

Expand Down Expand Up @@ -1370,6 +1369,25 @@ describe('React', () => {
])
})

it('should warn if pure option is present', () => {
let consoleSpy = expect.spyOn(console, 'error')

@connect.options({ pure: false })(() => {
return {}
})
class C extends Component {
render() {
return <div />
}
}

TestUtils.renderIntoDocument(
<C />
)

expect(consoleSpy.calls[0].arguments[0]).toEqual('Warning: `pure` option is no longer supported')
})

it('should shallowly compare the requests to prevent unnecessary fetches', (done) => {
@connect(({ foo }) => ({
testFetch: `/resource/${foo.FOO}`,
Expand Down

0 comments on commit 32ff72b

Please sign in to comment.