From 094b5ecbe47e16dc03e787ca91d518efe712cc14 Mon Sep 17 00:00:00 2001 From: Gert Hengeveld Date: Wed, 31 Aug 2016 15:20:46 +0200 Subject: [PATCH] Remove options to pass ref prop, because it was never supposed to be possible, but it might in the future. See facebook/react#4213 --- src/Checkbox.js | 5 +---- src/Input.js | 5 +---- src/Radio.js | 5 +---- src/Select.js | 5 +---- src/Textarea.js | 5 +---- test/specs/Checkbox.spec.js | 6 ------ test/specs/Input.spec.js | 6 ------ test/specs/Radio.spec.js | 6 ------ test/specs/Select.spec.js | 6 ------ test/specs/Textarea.spec.js | 6 ------ 10 files changed, 5 insertions(+), 50 deletions(-) diff --git a/src/Checkbox.js b/src/Checkbox.js index 3e24965..f1de18c 100644 --- a/src/Checkbox.js +++ b/src/Checkbox.js @@ -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 @@ -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: () => {}, } diff --git a/src/Input.js b/src/Input.js index 6943909..cd73b73 100644 --- a/src/Input.js +++ b/src/Input.js @@ -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 @@ -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: () => {}, } diff --git a/src/Radio.js b/src/Radio.js index 0c5771f..b33cdd0 100644 --- a/src/Radio.js +++ b/src/Radio.js @@ -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 @@ -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: () => {}, } diff --git a/src/Select.js b/src/Select.js index 1d7d7f9..3962141 100644 --- a/src/Select.js +++ b/src/Select.js @@ -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) @@ -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: () => {}, } diff --git a/src/Textarea.js b/src/Textarea.js index 63fd785..29355fe 100644 --- a/src/Textarea.js +++ b/src/Textarea.js @@ -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 @@ -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: () => {}, } diff --git a/test/specs/Checkbox.spec.js b/test/specs/Checkbox.spec.js index 1068e91..e2cddcf 100644 --- a/test/specs/Checkbox.spec.js +++ b/test/specs/Checkbox.spec.js @@ -35,12 +35,6 @@ describe('Checkbox', () => { expect(input.prop('className')).to.equal('fancy') }) - it('should trigger the ref callback', () => { - const ref = sinon.spy() - mountForm() - expect(ref).to.have.been.called() - }) - describe('when changing selection', () => { it('should update its value, replacing the initial value', () => { const input = mountForm().find('input') diff --git a/test/specs/Input.spec.js b/test/specs/Input.spec.js index 30921e9..e421c17 100644 --- a/test/specs/Input.spec.js +++ b/test/specs/Input.spec.js @@ -40,12 +40,6 @@ describe('Input', () => { expect(input.prop('className')).to.equal('fancy') }) - it('should trigger the ref callback', () => { - const ref = sinon.spy() - mountForm() - expect(ref).to.have.been.called() - }) - describe('when entering data', () => { it('should update its value, replacing the initial value', () => { const input = mountForm().find('input') diff --git a/test/specs/Radio.spec.js b/test/specs/Radio.spec.js index 75611a8..afdd50c 100644 --- a/test/specs/Radio.spec.js +++ b/test/specs/Radio.spec.js @@ -35,12 +35,6 @@ describe('Radio', () => { expect(input.prop('className')).to.equal('fancy') }) - it('should trigger the ref callback', () => { - const ref = sinon.spy() - mountForm() - expect(ref).to.have.been.called() - }) - describe('when changing selection', () => { it('should update its value, replacing the initial value', () => { const inputs = mountForm( diff --git a/test/specs/Select.spec.js b/test/specs/Select.spec.js index f677553..7153b7e 100644 --- a/test/specs/Select.spec.js +++ b/test/specs/Select.spec.js @@ -45,12 +45,6 @@ describe('Select', () => { expect(select.prop('className')).to.equal('fancy') }) - it('should trigger the ref callback', () => { - const ref = sinon.spy() - mountForm().find('select') expect(select.find('option').length).to.equal(3) diff --git a/test/specs/Textarea.spec.js b/test/specs/Textarea.spec.js index f12474b..a3538d6 100644 --- a/test/specs/Textarea.spec.js +++ b/test/specs/Textarea.spec.js @@ -35,12 +35,6 @@ describe('Textarea', () => { expect(textarea.prop('className')).to.equal('fancy') }) - it('should trigger the ref callback', () => { - const ref = sinon.spy() - mountForm(