My entry into ReactJs is way more challenging than I thought it would be. Since my last blog I leveled up my Js, I was feeling pretty good about myself. Apparently I can’t react fast enough though. When I went from Ruby to Rails it was just take your methods and write them in these erb tags.
It was a bit/still confusing when you would use “<%=” or “<%”. It looks you use the “<%” when you are making a method and use “<%=” when you are going to be using an instance variable.
Now I would go more in-depth if this was a rails post but sadly this is not. I just miss Ruby even with those erbs. Bringing up rails isn’t completely irrelevant to my jump from regular Js to ReactJs, both Rails and React built on top of the language that I was learning before it. Something about React has me unprepared.
What Is This?
When you are using JSX there is a lot of this being thrown around. I’m sure one day it won’t be as confusing but I know if I mess up the scope, this becomes that this when, I want it to be this this. This will always be some form of this, always true to itself. Now I may have purposely explained this poorly, but that is actually what kind of problems you can face when using “this”. I’m probably just getting too hooked on the semantics. So let’s see what some JSX looks like.
On the ReactJs website, They demonstrated how a to do app would be done in react js. At the very top is says …. extends React.Component… if you are familiar with Ruby models it is similar to how you would make a model inherit from Active Record. In ReactJs these are called components. Just like in Ruby/Rails you write all your instance methods here. So components by themselves can’t be what is confusing me let’s look at some other elements.
There is another element you will come across when writing or reading ReactJs code and that is props. Props are similar to params and they are generated by the parent element and passed down to the child component. On paper I know what props are, in practice…
Especially when “this” determines the props, I’m definitely getting confused when the “this” is interacting with the props. Learning a new language is hard. I think it is important to find some commonalities in the language so it seems less foreign and more like something you’ve forgotten. Foreign tends to strike fear, while forgotten sounds familiar. Since I believe my problems to stem from my lack of props knowledge, I found a blog about it. Hopefully it will help you as much as I believe it will help me.
Next time? Some time I hope to tell you guys how I changed my first app into a react app. In my first blog I mentioned that CLI app was and wasn’t my first app. I want to see how the code will change, how or if I will store the poems differently. What features I didn’t think up before, or wasn’t possible with my lack of knowledge will be added to first app remastered.