reset t0 default value when optin values gets an update

This commit is contained in:
arpitnath 2021-10-29 20:29:17 +05:30
parent 56165ad8bd
commit c0bcaa1d7f

View file

@ -63,6 +63,19 @@ export const DropDown = function DropDown({
const value = currentValueProperty ? currentValueProperty.value : '';
const [currentValue, setCurrentValue] = useState('');
const [optionValues, setOptionValue] = useState(() => selectOptions);
useEffect(() => {
const nextOptionValues = JSON.stringify(parsedValues);
const prevOptionValues = JSON.stringify(optionValues);
if (nextOptionValues !== prevOptionValues) {
setOptionValue(() => JSON.parse(nextOptionValues));
setCurrentValue('');
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [parsedValues]);
let newValue = value;
if (currentValueProperty && currentState) {
newValue = resolveReferences(currentValueProperty.value, currentState, '');