Got a file A with almost 2000 lines. Yes, a lot.
So firstly I would need to divide the entire file into smaller sections, so I will need to move a lot of functions to file B from file A and call them in file A to be executed.
Problem is that most of those functions use setState(), gets additional variables from local storage or/and are passed on etc. And there are 41 of them
Example function that needs to be moved to file B from file A
onSubmittedForUserIDChange = (e) => {
const { value } = e.target;
const { submitForOtherUser } = this.state;
if (!submitForOtherUser) {
this.setState({
submittedForUserID: +value,
submitForOtherUser: !submitForOtherUser,
category_id: null,
event_type_id: null,
warning: null,
});
} else {
this.setState({
submitForOtherUser: !submitForOtherUser,
submittedForUserID: +localStorage.getItem("user_id"),
});
}
};
It is called in file A jsx component
<select
className="form-control"
name="submittedForUserID"
onChange={this.onSubmittedForUserIDChange}
value={
submittedForUserID === +localStorage.getItem("user_id")
? "-1"
: submittedForUserID
}
disabled={disabled}
required
>
Tried several VSCode extensions that were "supposed" to help with this but really didn't, such as Glean, Abracadabra refractor this!, JS CodeFormer.
Would appreciate tips on how to do it faster than manually
Edit note: Redux is not used in project