diff --git a/packages/core/helper-plugin/lib/src/components/GenericInput/index.js b/packages/core/helper-plugin/lib/src/components/GenericInput/index.js index 2860da3e25..8ad1668ab2 100644 --- a/packages/core/helper-plugin/lib/src/components/GenericInput/index.js +++ b/packages/core/helper-plugin/lib/src/components/GenericInput/index.js @@ -38,7 +38,7 @@ const GenericInput = ({ required, step, type, - value, + value: defaultValue, isNullable, ...rest }) => { @@ -47,6 +47,10 @@ const GenericInput = ({ const CustomInput = customInputs ? customInputs[type] : null; + // the API always returns null, which throws an error in React, + // therefore we cast this case to undefined + const value = defaultValue ?? undefined; + if (CustomInput) { return ( onChange({ target: { name, value: null, type } })} placeholder={formattedPlaceholder} required={required} - value={value ? new Date(value) : null} + value={value && new Date(value)} selectedDateLabel={formattedDate => `Date picker, current is ${formattedDate}`} /> ); @@ -221,7 +225,7 @@ const GenericInput = ({ placeholder={formattedPlaceholder} required={required} step={step} - value={value ?? null} + value={value} /> ); } @@ -240,7 +244,7 @@ const GenericInput = ({ placeholder={formattedPlaceholder} required={required} type="email" - value={value || ''} + value={value} /> ); } @@ -261,7 +265,7 @@ const GenericInput = ({ placeholder={formattedPlaceholder} required={required} type="text" - value={value || ''} + value={value} /> ); } @@ -303,7 +307,7 @@ const GenericInput = ({ placeholder={formattedPlaceholder} required={required} type={showPassword ? 'text' : 'password'} - value={value || ''} + value={value} /> ); } @@ -322,7 +326,7 @@ const GenericInput = ({ }} placeholder={formattedPlaceholder} required={required} - value={value || ''} + value={value} > {options.map(({ metadatas: { intlLabel, disabled, hidden }, key, value }) => { return ( @@ -348,7 +352,7 @@ const GenericInput = ({ required={required} placeholder={formattedPlaceholder} type={type} - value={value || ''} + value={value} > {value} @@ -415,7 +419,7 @@ GenericInput.defaultProps = { required: false, options: [], step: 1, - value: '', + value: undefined, }; GenericInput.propTypes = {