Learnings on using React

By wabinab | work_learning | 15 Mar 2022


I'm a backend developer. Frontend is quite new to me, though actually learning it, it doesn't seems all bad. Though some parts of designing is quite annoying, especially with the flexibility of HTML, CSS, Javascript, etc that specify "configuration over convention" (lots of choice for you to choose and it's up to you) when one works better with "convention over configuration" (predefined set of values where you can type-write quickly without worrying too much about small details). The past few days one was writing using React, and one want to share some learnings with React, and some of my opinions and how one feels using React.

 

Few annoying things

The most annoying thing you encounter when developing a React app is the white screen of death (WSoD). Thing is, one runs npm run dev on the console to start the localhost, but when this happens, it didn't display anything. No reaction means difficulty debugging. Of course, there are some online teachings on how to handle this here, but it's not what one wants. For professionals, they might already know this, but you can show the error using your browser console. In Chrome/Brave, this is F12 then click on the console tab. There, you can see your errors, hence finally debugging what's happening.

Another annoying thing is how to design the app. When one uses the create-near-app by default (for creating a React frontend developing the NEAR Protocol), all the code are in one file. Everything, including the design, is in one file. For people with React experiences, this isn't difficult to change, to modularize. For me, it isn't. It takes me some time to figure out how to create partials and inserting to it. Particularly, creating constants (const) that take in some parameters and returning them by inserting them into the corresponding location, one can start to create layers of abstraction, factory methods, etc on designing the app. One made the mistake of designing directly with .html file but it requires .js file since it's not a static page.

Third is the react-render-dom not working, because one doesn't understand how it works with the already-created app. react-render-dom seems to work if you have a render() component, and directing it to sub-pages is a common example online. What's difficult is the default app that comes for mine doesn't have a render(), but somehow it renders? One have totally no idea how it works, but one knows for hyperlinks, one requires to resort back to the old-style HTML <a href="...">Some name</a> and work out with some windows configuration pass in configuration like home page location, etc. It isn't too difficult because pages are relative, though one don't feel so comfortable as it hard-code quite a bit.

 

For the future

Although NEAR don't support Ruby on Rails as frontend, one plans to make an adapter for the RPC and plug it in. Of course, one doesn't know a lot of Rails, only started learning 2-3 months ago, and even so, only during the weekends. So that's another thing to look forward in the future. Besides, one really like how Rails program compared to React, because one is a Python developer, and Ruby looks more like Python compared to React code (using snake case instead of camel case [ouch my pinky hurts pressing shift all the time], and using no curly braces and no multiple brackets wrapping (( { } )) which one found super-duper-annoying. If one manage to port it to Rails, one will write another article about it, though one don't know when that will come.

P.S. In case you ask why underscore one don't uses shift when it requires, because one uses the French AZERTY rather QWERTY keyboard. So, there are some difficulty with this keyboard but some advantage as well. Disadvantage is one's keyboard isn't designed for French AZERTY, so there's no key for < and >, and some other keys requires using the ALT+RIGHT key to activate. Advantage is less compared to disadvantage, including underscore don't require pressing Shift. Anyway, one used to AZERTY now and not planning to change back to QWERTY yet, and one don't recommend it for programming languages that requires lots of ->, it's nightmarish.

 

Conclusion

One aren't very happy coding with React. The code is mostly understandable, including the logic and the flow. It's more about how the language is defined aren't my type. You're welcome to use it if you like how it works, though.

[This article might not be final, one might update it if one encounters further thoughts and conclusions].

(This article is originally posted on read.cash)

How do you rate this article?


1

0

wabinab
wabinab

Software and ML developer, writer, jack of most trades.


work_learning
work_learning

These are about "work" learning, whatever one considered as work (not what the society considered as work).

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.