Skip to content

Commit

Permalink
Remove options to pass ref prop, because it was never supposed to be …
Browse files Browse the repository at this point in the history
…possible, but it might in the future. See facebook/react#4213
  • Loading branch information
ghengeveld committed Aug 31, 2016
1 parent 5339f49 commit 094b5ec
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 50 deletions.
5 changes: 1 addition & 4 deletions src/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ export default class Checkbox extends React.Component {
}
ref(element) {
const { form } = this.context
const { name, initial, ref } = this.props
const { name, initial } = this.props
form.register(name, element ? element.checked : undefined, initial)
ref(element)
}
render() {
const { initial: _, ...props } = this.props
Expand All @@ -46,13 +45,11 @@ Checkbox.propTypes = {
name: React.PropTypes.string.isRequired,
id: React.PropTypes.string,
initial: React.PropTypes.bool,
ref: React.PropTypes.func,
onChange: React.PropTypes.func,
}

Checkbox.defaultProps = {
initial: false,
ref: () => {},
onChange: () => {},
}

Expand Down
5 changes: 1 addition & 4 deletions src/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ export default class Input extends React.Component {
}
ref(element) {
const { form } = this.context
const { name, initial, ref } = this.props
const { name, initial } = this.props
form.register(name, element ? element.value : undefined, initial)
ref(element)
}
render() {
const { initial: _, ...props } = this.props
Expand All @@ -46,14 +45,12 @@ Input.propTypes = {
id: React.PropTypes.string,
type: React.PropTypes.string,
initial: React.PropTypes.string,
ref: React.PropTypes.func,
onChange: React.PropTypes.func,
}

Input.defaultProps = {
type: 'text',
initial: '',
ref: () => {},
onChange: () => {},
}

Expand Down
5 changes: 1 addition & 4 deletions src/Radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ export default class Radio extends React.Component {
}
ref(element) {
const { form } = this.context
const { name, initial, ref } = this.props
const { name, initial } = this.props
form.register(name, element && element.checked ? element.value : undefined, initial)
ref(element)
}
render() {
const { initial: _, ...props } = this.props
Expand All @@ -51,12 +50,10 @@ Radio.propTypes = {
value: React.PropTypes.string.isRequired,
id: React.PropTypes.string,
initial: React.PropTypes.string,
ref: React.PropTypes.func,
onChange: React.PropTypes.func,
}

Radio.defaultProps = {
ref: () => {},
onChange: () => {},
}

Expand Down
5 changes: 1 addition & 4 deletions src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ export default class Select extends React.Component {
}
ref(element) {
const { form } = this.context
const { name, initial, ref } = this.props
const { name, initial } = this.props
form.register(name, element ? this.getSelection(element) : undefined, initial)
ref(element)
}
renderOptions(options) {
return Array.isArray(options)
Expand Down Expand Up @@ -60,13 +59,11 @@ Select.propTypes = {
initial: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.array]),
options: React.PropTypes.oneOfType([React.PropTypes.object, React.PropTypes.array]),
children: React.PropTypes.node,
ref: React.PropTypes.func,
onChange: React.PropTypes.func,
}

Select.defaultProps = {
multiple: false,
ref: () => {},
onChange: () => {},
}

Expand Down
5 changes: 1 addition & 4 deletions src/Textarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ export default class Textarea extends React.Component {
}
ref(element) {
const { form } = this.context
const { name, initial, ref } = this.props
const { name, initial } = this.props
form.register(name, element ? element.value : undefined, initial)
ref(element)
}
render() {
const { initial: _, ...props } = this.props
Expand All @@ -45,13 +44,11 @@ Textarea.propTypes = {
name: React.PropTypes.string.isRequired,
id: React.PropTypes.string,
initial: React.PropTypes.string,
ref: React.PropTypes.func,
onChange: React.PropTypes.func,
}

Textarea.defaultProps = {
initial: '',
ref: () => {},
onChange: () => {},
}

Expand Down
6 changes: 0 additions & 6 deletions test/specs/Checkbox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ describe('Checkbox', () => {
expect(input.prop('className')).to.equal('fancy')
})

it('should trigger the ref callback', () => {
const ref = sinon.spy()
mountForm(<Checkbox name="val" ref={ref} />)
expect(ref).to.have.been.called()
})

describe('when changing selection', () => {
it('should update its value, replacing the initial value', () => {
const input = mountForm(<Checkbox name="val" initial={!!true} />).find('input')
Expand Down
6 changes: 0 additions & 6 deletions test/specs/Input.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ describe('Input', () => {
expect(input.prop('className')).to.equal('fancy')
})

it('should trigger the ref callback', () => {
const ref = sinon.spy()
mountForm(<Input name="val" ref={ref} />)
expect(ref).to.have.been.called()
})

describe('when entering data', () => {
it('should update its value, replacing the initial value', () => {
const input = mountForm(<Input name="val" initial="Init" />).find('input')
Expand Down
6 changes: 0 additions & 6 deletions test/specs/Radio.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ describe('Radio', () => {
expect(input.prop('className')).to.equal('fancy')
})

it('should trigger the ref callback', () => {
const ref = sinon.spy()
mountForm(<Radio name="val" value="yes" ref={ref} />)
expect(ref).to.have.been.called()
})

describe('when changing selection', () => {
it('should update its value, replacing the initial value', () => {
const inputs = mountForm(
Expand Down
6 changes: 0 additions & 6 deletions test/specs/Select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ describe('Select', () => {
expect(select.prop('className')).to.equal('fancy')
})

it('should trigger the ref callback', () => {
const ref = sinon.spy()
mountForm(<Select name="val" ref={ref} />)
expect(ref).to.have.been.called()
})

it('should also accept options as an array', () => {
const select = mountForm(<Select name="val" options={['one', 'two', 'three']} />).find('select')
expect(select.find('option').length).to.equal(3)
Expand Down
6 changes: 0 additions & 6 deletions test/specs/Textarea.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ describe('Textarea', () => {
expect(textarea.prop('className')).to.equal('fancy')
})

it('should trigger the ref callback', () => {
const ref = sinon.spy()
mountForm(<Textarea name="val" ref={ref} />)
expect(ref).to.have.been.called()
})

describe('when entering data', () => {
it('should update its value, replacing the initial value', () => {
const textarea = mountForm(<Textarea name="val" initial="Init" />).find('textarea')
Expand Down

0 comments on commit 094b5ec

Please sign in to comment.