diff options
| author | 2021-01-17 02:47:07 +0300 | |
|---|---|---|
| committer | 2021-01-17 02:54:12 +0300 | |
| commit | a084f79568f2b4808789bb65034e677a4ffdd520 (patch) | |
| tree | b0c954f1045cadf0406d16095183cbb76ed22001 | |
| parent | Updates Switch Statement Indent (diff) | |
Removes Leading Underscore From Variables
Co-authored-by: Joe Banks <[email protected]>
Signed-off-by: Hassan Abouelela <[email protected]>
| -rw-r--r-- | src/components/InputTypes/index.tsx | 4 | ||||
| -rw-r--r-- | src/components/Question.tsx | 18 | 
2 files changed, 11 insertions, 11 deletions
| diff --git a/src/components/InputTypes/index.tsx b/src/components/InputTypes/index.tsx index 5154f9c..f1e0b30 100644 --- a/src/components/InputTypes/index.tsx +++ b/src/components/InputTypes/index.tsx @@ -11,7 +11,7 @@ import React, { ChangeEvent } from "react";  import { QuestionType } from "../../api/question";  import { QuestionProp } from "../Question"; -const _require_options: Array<QuestionType> = [ +const require_options: Array<QuestionType> = [      QuestionType.Radio,      QuestionType.Checkbox,      QuestionType.Select, @@ -26,7 +26,7 @@ export default function create_input({ question, public_state }: QuestionProp, h      let options: string[] = question.data["options"];      // Catch input types that require options but don't have any -    if ((options === undefined || typeof options !== "object") && _require_options.includes(question.type)) { +    if ((options === undefined || typeof options !== "object") && require_options.includes(question.type)) {          // TODO: Implement some sort of warning here          options = [];      } diff --git a/src/components/Question.tsx b/src/components/Question.tsx index 34d12f7..735d69b 100644 --- a/src/components/Question.tsx +++ b/src/components/Question.tsx @@ -6,7 +6,7 @@ import { Question, QuestionType } from "../api/question";  import { selectable } from "../commonStyles";  import create_input from "./InputTypes"; -const _skip_normal_state: Array<QuestionType> = [ +const skip_normal_state: Array<QuestionType> = [      QuestionType.Radio,      QuestionType.Checkbox,      QuestionType.Select, @@ -28,12 +28,12 @@ class RenderedQuestion extends React.Component<QuestionProp> {              this.handler = this.normal_handler.bind(this);          } -        if (!_skip_normal_state.includes(props.question.type)) { -            this._setState("value", ""); +        if (!skip_normal_state.includes(props.question.type)) { +            this.setPublicState("value", "");          }      } -    _setState(target: string, value: string | boolean | null, callback?:() => void): void { +    setPublicState(target: string, value: string | boolean | null, callback?:() => void): void {          this.setState({[target]: value}, callback);          this.props.public_state.set(target, value);      } @@ -52,7 +52,7 @@ class RenderedQuestion extends React.Component<QuestionProp> {                  break;              case "radio": -                // This handles radios and ranges, as they are both based on the same fundamental input type +            // This handles radios and ranges, as they are both based on the same fundamental input type                  target = "value";                  if (event.target.parentElement) {                      value = event.target.parentElement.innerText.trimEnd(); @@ -66,7 +66,7 @@ class RenderedQuestion extends React.Component<QuestionProp> {                  value = event.target.value;          } -        this._setState(target, value); +        this.setPublicState(target, value);          // Toggle checkbox class          if (event.target.type == "checkbox" && event.target.parentElement !== null) { @@ -76,7 +76,7 @@ class RenderedQuestion extends React.Component<QuestionProp> {      }      text_area_handler(event: ChangeEvent<HTMLTextAreaElement>): void { -        this._setState("value", event.target.value); +        this.setPublicState("value", event.target.value);      }      componentDidMount(): void { @@ -91,14 +91,14 @@ class RenderedQuestion extends React.Component<QuestionProp> {                      }                      options.forEach((option, index) => { -                        this._setState(`${("000" + index).slice(-4)}. ${option}`, false); +                        this.setPublicState(`${("000" + index).slice(-4)}. ${option}`, false);                      });                      break;                  case QuestionType.Range:                  case QuestionType.Radio:                  case QuestionType.Select: -                    this._setState("value", null); +                    this.setPublicState("value", null);                      break;              }          } | 
