<commit_before>import * as React from "react";
import { Checkbox, ICheckboxProps, Label } from "office-ui-fabric-react";
import { BaseField } from "../../common";
import { IFieldBoolean, IFieldBooleanProps, IFieldBooleanState } from "../../definitions";

/**
 * Boolean field
 */
export class FieldBoolean extends BaseField<IFieldBooleanProps, IFieldBooleanState> implements IFieldBoolean {
    // Render the field
    renderField() {
        // Update the checkbox properties
        let props: ICheckboxProps = this.props.props || {};
        props.checked = this.getValue();
        props.onChange = this.onChange;

        // Render the component
        return (
            <div>
                <Label ref="label">{props.label || this.state.label}</Label>
                <Checkbox {...props as any} ref="checkbox" />
            </div>
        );
    }

    // Method to get the value
    private getValue = () => {
        // Get the field value
        let value = this.getFieldValue();

        // Return a boolean value
        return typeof (value) === "boolean" ? value : false;
    }

    // The on change event
    private onChange = () => {
        let value = (this.refs["checkbox"] as Checkbox).checked;

        // Update the value
        this.updateValue(value);
    }
}<commit_msg>Fixed bug w/ the boolean field. The state value was not updating.<commit_after>import * as React from "react";
import { Checkbox, ICheckboxProps, Label } from "office-ui-fabric-react";
import { BaseField } from "../../common";
import { IFieldBoolean, IFieldBooleanProps, IFieldBooleanState } from "../../definitions";

/**
 * Boolean field
 */
export class FieldBoolean extends BaseField<IFieldBooleanProps, IFieldBooleanState> implements IFieldBoolean {
    // Render the field
    renderField() {
        // Update the checkbox properties
        let props: ICheckboxProps = this.props.props || {};
        props.checked = this.getValue();
        props.onChange = this.onChange;

        // Render the component
        return (
            <div>
                <Label ref="label">{props.label || this.state.label}</Label>
                <Checkbox {...props as any} ref="checkbox" />
            </div>
        );
    }

    // Method to get the value
    private getValue = () => {
        // Get the field value
        let value = this.getFieldValue();

        // Return a boolean value
        return typeof (value) === "boolean" ? value : false;
    }

    // The on change event
    private onChange = (ev: React.MouseEvent<HTMLInputElement>, checked: boolean) => {
        // Update the value
        this.updateValue(checked);
    }
}
{'fraction_non_alphanumeric': 0.12631975867269984, 'fraction_numerical': 0.0, 'mean_word_length': 2.2353658536585366, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 20, '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': '5511297', 'n_tokens_mistral': 709, 'n_tokens_neox': 697, 'n_words': 210}