As discussed last week I am celebrating Hacktoberfest by spending the month of October trying to complete four real world contributions via Github. I wanted to try and get ahead, or at least not fall behind, because I know life can get busy so securing an issue to do might take some more time than expected. This caused me to spend quite some time over the span of a couple days at the beginning of the month just hitting refresh every few hours on the “good first issue” list, looking for an appropriate issue. After some time, and with nothing that was jumping out at me, I decided to take a look at the trending repos. It was there where I found a really cool project called FreeTube, but more about that next week, hopefully. After spending some time with the FreeTube code I realized that I’m gonna need some more time with it to understand what I need to do. Back to the most recent issues search.
I found an issue that at a glance, seemed pretty easy. I just had to write some documentation, perfect. This would let me complete another PR and give me more time to work on FreeTube. A week went by and I finally decided to knock off this documentation issue. I fork and clone the repo, follow the install instructions and then I try to figure out how to run it. Hmmm, something doesn’t seem right. I don’t see any code to initiate the application. Also, when I was reading other documentation I tried to search for the implementation in said documentation but there was no results. Odd.
Turns out I should have read the documentation a little closer. You need an iPhone with the HealthKit application on it in order to properly run the code and to properly document the results. I have never owned an iPhone in my life so after confirming my suspicions I went into a slight panic mode. I need another issue, luckily I still had a week before this blog is due.
After spending some more time searching I found an issue to stop a submit button from sending multiple requests in a React app. Ok, I did that in Angular. I should be able to do that in React. At first I was trying to create my own function that would get called on a click event. That function would set a variable used to set the disabled attribute. Only problem is that I can’t declare a variable outside of the constructor, ok I’ll just pop this variable in the… construc… hmmm. I can’t find the constructor. I thought about making one but that would change the code to much and would probably get rejected.
function Login() {
const [modalIsOpen, setModalIsOpen] = useState(true);
const {register, handleSubmit, errors} = useForm();
function closeModal() {
setModalIsOpen(false);
}
I wasn’t familiar with what useState did so I ignored it at first, but after hitting that roadblock I decided to read the documentation on it and figured that this would solve my problem!
const [disable, setDisabled] = useState(false);
After adding that line along with an event handler I was able to submit my second PR. The reviewer responded the following day and wanted me to add some rust code to a different file. I never used rust before but I think the reviewer just wanted me to copy and paste the code snippet into a file so that it gets to the main branch sooner. I had a pretty busy Tuesday so I was gonna work on it the next day. I went to work on it first thing in the morning and the reviewer had deleted the comments and just said to disregard the last message since someone else was able to submit a PR with the required snippet. All that was left was for me to update the current branch, and after getting the green lights from the tester my code was successfully merged. Crisis averted!