Skip to content

Commit

Permalink
Don't use initialConfig when checking immutableProps (#3052)
Browse files Browse the repository at this point in the history
This parameter may be undefined, as all configs can be
defined via props.

Fixes #3048
  • Loading branch information
gustavohenke authored and erikras committed Jun 14, 2017
1 parent 22f27de commit d5d0d24
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions src/__tests__/reduxForm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,37 @@ const describeReduxForm = (name, structure, combineReducers, expect) => {
}).toNotThrow()
})

it('should update without error when there is no config', () => {
const store = makeStore()
const Form = () => <div />
const Decorated = reduxForm()(Form)

class Container extends Component {
constructor(props) {
super(props)
this.state = {}
}

render() {
return (
<Provider store={store}>
<div>
<Decorated form='formname' foo={this.state.foo} />
<button onClick={() => this.setState({ foo: 'bar' })} />
</div>
</Provider>
)
}
}

const dom = TestUtils.renderIntoDocument(<Container />)

expect(() => {
const button = TestUtils.findRenderedDOMComponentWithTag(dom, 'button')
TestUtils.Simulate.click(button)
}).toNotThrow()
})

it('should provide the correct props', () => {
const props = propChecker({})
expect(Object.keys(props).sort()).toEqual([
Expand Down
2 changes: 1 addition & 1 deletion src/createReduxForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ const createReduxForm = structure => {

shouldComponentUpdate(nextProps) {
if (!this.props.pure) return true
const { immutableProps = [] } = initialConfig
const { immutableProps = [] } = config
return Object.keys(nextProps).some(prop => {
// useful to debug rerenders
// if (!plain.deepEqual(this.props[ prop ], nextProps[ prop ])) {
Expand Down

0 comments on commit d5d0d24

Please sign in to comment.