Learning React

Today at we finished our first sprint for React, having just been introduced to React barely more than 24 hours ago. The hardest part for me is to have a full understanding of the chains of props that sometimes occur (meaning App.js may pass it’s state as a prop to videoList and videoList might pass that to one of it’s elements to be used for a function, while it is still bound in scope to App.js).

After having to walk myself through the code every time a change was needed, we were able to implement a video search function that returned videos from youtube’s API. Our APIs kept running hitting our query limit, but the very fact that we were able to figure out how to use our API keys to get data back from the server still surprises me. Postman was a big help; I can’t imagine learning how to leverage APIs without it.

My current understanding of passing in functions as props is as follows: you declare a function in a certain component — say, App.js. Then, when rendering other components from App.js’s render call, you declare the HTML element as such: <div><Example propname={this.function.bind(this)}></div> . Then, that can be accessed in the example component with props.propname(). It sounds simple enough, but it becomes difficult to understand if those become chained through multiple components — figuring out what to change in which file and which component can be difficult, requiring you to step though your code again.

After even only a few days with react, I understand why people prefer it to jQuery for writing interactive web pages. The rereading upon state changes is extremely useful (it’s also where the name ‘React’ comes from — it’s reacting to changes caused by the user). However, it is going to take me atleast as long to learn React as it took me to learn jQuery. With increased capabilities comes more principles and syntax to wrap my head around.

This is something I will have to review slides on many times before it becomes second nature. I have also been messing around with the program we wrote for the sprint, inserting console logs and debuggers, to affirm that my preconceptions about what will be logged match up with reality. For me, messing around with code helps me learn far more than any other method of learning. I have to do it myself rather than listen. Listening helps me get my bearings, but for it to become second nature, I — like anyone else — need to actually mess around in the code in a hands-on way.