Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
fix(checkbox,radio): value should be optional (#419)
Browse files Browse the repository at this point in the history
* fix(checkbox): remove isRequired from `value` prop

* fix(radio): remove isRequired from value and fix Lint issues
  • Loading branch information
HendrikThePendric authored and varl committed Nov 25, 2019
1 parent 4d70143 commit 05306a2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class Checkbox extends Component {
Checkbox.propTypes = {
onChange: propTypes.func.isRequired,

value: propTypes.string.isRequired,
value: propTypes.string,
name: propTypes.string.isRequired,
label: propTypes.string.isRequired,
tabIndex: propTypes.string,
Expand Down
3 changes: 2 additions & 1 deletion src/Checkbox/Input.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component, Fragment, createRef } from 'react'
import React, { Component, createRef } from 'react'
import propTypes from 'prop-types'

export class Input extends Component {
Expand Down Expand Up @@ -52,6 +52,7 @@ export class Input extends Component {
Input.propTypes = {
onChange: propTypes.func.isRequired,
name: propTypes.string.isRequired,
value: propTypes.string,

tabIndex: propTypes.string,

Expand Down
45 changes: 15 additions & 30 deletions src/Radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,20 @@ const icons = css.resolve`
}
`

const Input = React.forwardRef(
(
{ name, value, checked, disabled, tabIndex, onChange, onFocus, onBlur },
ref
) => (
<div>
<input
type="radio"
ref={ref}
name={name}
value={value}
checked={checked}
disabled={disabled}
tabIndex={tabIndex}
onChange={onChange}
onFocus={onFocus}
onBlur={onBlur}
/>

<style jsx>{`
div {
height: 0;
width: 0;
overflow: hidden;
}
`}</style>
</div>
)
)
const Input = React.forwardRef((props, ref) => (
<div>
<input type="radio" ref={ref} {...props} />

<style jsx>{`
div {
height: 0;
width: 0;
overflow: hidden;
}
`}</style>
</div>
))
Input.displayName = 'Input'

class Radio extends Component {
ref = createRef()
Expand Down Expand Up @@ -174,7 +159,7 @@ Radio.propTypes = {
onChange: propTypes.func.isRequired,

name: propTypes.string.isRequired,
value: propTypes.string.isRequired,
value: propTypes.string,
className: propTypes.string,
label: propTypes.string,
tabIndex: propTypes.string,
Expand Down

0 comments on commit 05306a2

Please sign in to comment.