/* eslint-disable react/forbid-prop-types */
import React from 'react';
import PropTypes from 'prop-types';
import { Picker } from '@react-native-picker/picker';

import { SUSSOL_ORANGE } from '../../../globalStyles/colors';

export const Select = ({ disabled, readonly, onChange, placeholder, options, value }) => {
  let pickers = options.enumOptions.map(({ label, value: enumValue }) => (
    <Picker.Item key={label} label={label} value={enumValue} color={SUSSOL_ORANGE} />
  ));

  const placeholderItem = (
    <Picker.Item key={placeholder} label={placeholder} value={placeholder} color={SUSSOL_ORANGE} />
  );

  pickers = [placeholderItem, ...pickers];

  return (
    <Picker
      mode="dropdown"
      enabled={!(disabled || readonly)}
      selectedValue={value}
      onValueChange={chosenValue => {
        // There is a requirement for 'empty'/placeholder entries to call on change with
        // undefined: https://github.com/rjsf-team/react-jsonschema-form/pull/451/files
        // however the placeholder value is passed by default as an empty string.
        if (chosenValue === '') onChange(undefined);
        else onChange(chosenValue);
      }}
    >
      {pickers}
    </Picker>
  );
};

Select.defaultProps = {
  readonly: false,
  value: '',
};

Select.propTypes = {
  options: PropTypes.object.isRequired,
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
  onChange: PropTypes.func.isRequired,
  disabled: PropTypes.bool.isRequired,
  readonly: PropTypes.bool,
  placeholder: PropTypes.string.isRequired,
};

@@ -50,16 +50,31 @@
 rt React
+, %7B useEffect %7D
  from 'r
@@ -80,16 +80,16 @@
 react';%0A
-
 import P
@@ -312,24 +312,32 @@
 tions, value
+, schema
  %7D) =%3E %7B%0A  l
@@ -635,16 +635,16 @@
 %3E%0A  );%0A%0A
-
   picker
@@ -679,16 +679,190 @@
 kers%5D;%0A%0A
+  useEffect(() =%3E %7B%0A    if (!options?.enumOptions?.find(o =%3E o.value === value)) %7B%0A      const %7B default: defaultValue %7D = schema;%0A      onChange(defaultValue);%0A    %7D%0A  %7D);%0A%0A
   return
@@ -1745,11 +1745,50 @@
 quired,%0A
+  schema: PropTypes.object.isRequired,%0A
 %7D;%0A

Add update to select widget