mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-29 13:06:03 +10:00
Require id only when label is given
This commit is contained in:
parent
77c7508af3
commit
ede46ae006
1 changed files with 7 additions and 1 deletions
|
|
@ -181,6 +181,11 @@ BirthdayInput.propTypes = {
|
|||
|
||||
const BirthdayInputFieldComponent = props => {
|
||||
const { rootClassName, className, id, label, input, meta } = props;
|
||||
|
||||
if (label && !id) {
|
||||
throw new Error('id required when a label is given');
|
||||
}
|
||||
|
||||
const classes = classNames(rootClassName || css.fieldRoot, className);
|
||||
const inputProps = { id, ...input };
|
||||
return (
|
||||
|
|
@ -195,13 +200,14 @@ const BirthdayInputFieldComponent = props => {
|
|||
BirthdayInputFieldComponent.defaultProps = {
|
||||
rootClassName: null,
|
||||
className: null,
|
||||
id: null,
|
||||
label: null,
|
||||
};
|
||||
|
||||
BirthdayInputFieldComponent.propTypes = {
|
||||
rootClassName: string,
|
||||
className: string,
|
||||
id: string.isRequired,
|
||||
id: string,
|
||||
label: string,
|
||||
input: object.isRequired,
|
||||
meta: object.isRequired,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue