Conditions | 1 |
Total Lines | 60 |
Code Lines | 53 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | import React, { Component } from "react"; |
||
34 | |||
35 | render() { |
||
36 | const triggerClass = classNames( |
||
37 | "profile-element", |
||
38 | "accordion", |
||
39 | "reference", |
||
40 | "modal-target-object", |
||
41 | { active: this.state.active }, |
||
42 | ); |
||
43 | return ( |
||
44 | <div className={triggerClass}> |
||
45 | <button |
||
46 | aria-expanded={this.state.active} |
||
47 | className="accordion-trigger" |
||
48 | tabIndex="0" |
||
49 | type="button" |
||
50 | onClick={this.handleTriggerClick} |
||
51 | > |
||
52 | {this.props.showStatus && ( |
||
53 | <div className="accordion-status"> |
||
54 | <i className="fas fa-check" /> |
||
55 | <i className="fas fa-exclamation-circle" /> |
||
56 | </div> |
||
57 | )} |
||
58 | <span className="accordion-title">{this.props.title}</span> |
||
59 | </button> |
||
60 | |||
61 | <div aria-hidden={!this.state.active} className="accordion-content"> |
||
62 | <form action={this.props.url} method="POST"> |
||
63 | <div className="form__wrapper"> |
||
64 | <div className="form-error box" /> |
||
65 | <div className="flex-grid"> |
||
66 | <div className="box med-1of2"> |
||
67 | <div |
||
68 | className={classNames("form__input- wrapper--float", { |
||
69 | active: this.state.name, |
||
70 | })} |
||
71 | > |
||
72 | <label |
||
73 | className="form__label" |
||
74 | htmlFor={`referenceName${this.props.id}`} |
||
75 | > |
||
76 | {this.props.lang.name_label} |
||
77 | </label> |
||
78 | <input |
||
79 | className="form__input" |
||
80 | id={`referenceName${this.props.id}`} |
||
81 | type="text" |
||
82 | name="name" |
||
83 | required |
||
84 | value={this.state.name} |
||
85 | onChange={this.handleNameChange} |
||
86 | /> |
||
87 | </div> |
||
88 | </div> |
||
89 | </div> |
||
90 | </div> |
||
91 | </form> |
||
92 | </div> |
||
93 | </div> |
||
94 | ); |
||
104 |