<commit_before>import * as React from 'react';
import { WrappedFieldMetaProps } from 'redux-form';

import { FieldError } from './FieldError';
import { FormField } from './types';

interface FormGroupProps extends FormField {
  meta: WrappedFieldMetaProps;
  children: React.ReactChildren;
}

export const FormGroup = (props: FormGroupProps) => {
  const { input, required, label, meta: {error}, children, ...rest } = props;
  return (
    <div className="form-group">
      <label className="control-label">
        {label}{required && <span className="text-danger"> *</span>}
      </label>
      {React.cloneElement((children as any), {input, ...rest})}
      <FieldError error={error}/>
    </div>
  );
};<commit_msg>Clear field in Redux-Form when field is unmounted [WAL-1343]<commit_after>import * as React from 'react';
// @ts-ignore
import { clearFields, WrappedFieldMetaProps } from 'redux-form';

import { FieldError } from './FieldError';
import { FormField } from './types';

interface FormGroupProps extends FormField {
  meta: WrappedFieldMetaProps;
  children: React.ReactChildren;
}

export class FormGroup extends React.PureComponent<FormGroupProps> {
  render() {
    const { input, required, label, meta: {error}, children, ...rest } = this.props;
    return (
      <div className="form-group">
        <label className="control-label">
          {label}{required && <span className="text-danger"> *</span>}
        </label>
        {React.cloneElement((children as any), {input, ...rest})}
        <FieldError error={error}/>
      </div>
    );
  }

  componentWillUnmount() {
    const { meta, input } = this.props;
    meta.dispatch(clearFields(meta.form, false, false, input.name));
  }
}
{'fraction_non_alphanumeric': 0.15236427320490367, 'fraction_numerical': 0.002335084646818447, 'mean_word_length': 3.6199460916442048, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6978956', 'n_tokens_mistral': 512, 'n_tokens_neox': 509, 'n_words': 134}