<commit_before>import React, { Component } from 'react';
import { Button, Input, Col, Row } from 'react-materialize';
import { reduxForm } from 'redux-form';
import { addRoom } from '../actions/rooms.action.js';

class AddRoomForm extends Component {
  render() {
    const { fields: { roomName, size, notes }, handleSubmit } = this.props;

    return (
      <form onSubmit={ handleSubmit(this.props.addRoom) } >
        <Col s={12}>
          <Row>
            <Input type="text" placeholder="Room Name" s={6} label="Room Name" { ...roomName } />
            <Input type="text" placeholder="Size" s={6} label="Size" { ...size } />
          </Row>
          <Row>
            <div class="input-field col s12">
              <label for="textarea1">Notes</label>
              <textarea id="textarea1" className="materialize-textarea" placeholder="Notes" { ...notes }></textarea>
            </div>
          </Row>
        </Col>
        <Button type="submit">Submit</Button>
      </form>
    );
  }
}

export default reduxForm({
  form: 'AddRoomForm',
  fields: ['roomName', 'size', 'notes'],
}, null, { addRoom })(AddRoomForm);<commit_msg>fix(add room form): form now clears on submit<commit_after>import React, { Component } from 'react';
import { Button, Input, Col, Row } from 'react-materialize';
import { reduxForm, reset } from 'redux-form';
import { addRoom } from '../actions/rooms.action.js';

class AddRoomForm extends Component {
  addRoom(newRoomObj) {
    console.log(newRoomObj, this);
    const {addRoom, dispatch} = this.props;
    addRoom(newRoomObj);
    dispatch(reset('AddRoomForm'));
  }

  render() {
    const { fields: { roomName, size, notes }, handleSubmit } = this.props;

    return (
      <form onSubmit={ handleSubmit(this.addRoom.bind(this)) } >
        <Col s={12}>
          <Row>
            <Input type="text" placeholder="Room Name" s={6} label="Room Name" { ...roomName } />
            <Input type="text" placeholder="Size" s={6} label="Size" { ...size } />
          </Row>
          <Row>
            <div class="input-field col s12">
              <label for="textarea1">Notes</label>
              <textarea id="textarea1" className="materialize-textarea" placeholder="Notes" { ...notes }></textarea>
            </div>
          </Row>
        </Col>
        <Button type="submit">Submit</Button>
      </form>
    );
  }
}

export default reduxForm({
  form: 'AddRoomForm',
  fields: ['roomName', 'size', 'notes'],
}, null, { addRoom })(AddRoomForm);

function mapDispatchToProps(dispatch) {
  return bindActionCreators(null, dispatch);
}
{'fraction_non_alphanumeric': 0.1673753382296096, 'fraction_numerical': 0.006184770003865481, 'mean_word_length': 2.718390804597701, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, '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': '817195', 'n_tokens_mistral': 796, 'n_tokens_neox': 774, 'n_words': 191}