static getDerivedStateFromProps()

in src/components/view/Filter/Filter.tsx [96:117]


  static getDerivedStateFromProps(nextProps: FilterProps, nextState: FilterState) {
    const fieldType = getSelectedFieldType(nextProps.selectedField, nextProps.schema);
    const type = fieldType?.dataType as PropertyType;
    const enumValues = getValues(fieldType);
    const values =
      showSpecialValues(nextProps.selectedOperators as Operator) || isInFilters(nextProps.selectedOperators as Operator)
        ? getFilterValues(type, enumValues as string[])
        : [];
    const filterValues = isBooleanType(type)
      ? nextProps.filterValues.map((value: any) => (value === true ? TRUE : value === false ? FALSE : value))
      : nextProps.filterValues;
    const selectedItem = getSelectedItem(type, enumValues, filterValues, values, nextState.selectedItem);

    return {
      operators: getOperators(type),
      fieldType: type,
      values,
      selectedItem,
      filterValues: nextProps.filterValues,
      dateValue: nextProps.filterValues?.[0] ? new Date(nextProps.filterValues[0]) : null
    };
  }