ReactJS without server-side routing

If you develop in ReactJS, you may know that routing happens on the client-side. But, the complexity of servers these days require mixed routing – on both client and server sides.

The main problem comes when users refresh a sub-page like https://www.splendoid.com/mypage, type directly the URL, or navigate to a bookmarked page, your app needs server-side routing or the server will show everyone’s favourite 404 error (Resource not found).

Read More

How to add comments in React JS

If you are new to React JS, you may be wondering how to make your code proper and add comments to it. To do that in a React component, you won’t be able to use the standard JavaScript annotation. The following code will display the text of the comment on your page.

Read More

React JS – registerServiceWorker() with create-react-app

When you use create-react-app to initiate a React JS project, you would get a line in index.js that will look like this:


registerServiceWorker();

I was asked a few times do you need it and for what. Technically, this is a decision by the creators of the create-react-app package to facilitate faster loading for offline or returning users.

Read More

Composition vs Inheritance in JavaScript

I was showing some of our juniors how to develop basic things in JavaScript and I realized there is a century-old (he-he) question – What to use: Composition or Inheritance when creating a hierarchy of objects?

In highly structured languages like C#, the answer of the question is kinda obvious. Yes, it’s use Inheritance of classes. But this question comes more and more with TypeScript, React, and other languages based on JavaScript. There JS’s flexibility still exists but the creators want you to use the power of the classes. 

Read More