Development

Learning React JS Part 1

React JS or just React is a very popular Javascript framework created by a software engineer at Facebook. The main focus of React is to build user interfaces (UI), with state management and rendering this state to the DOM.

Why learn React?

As wanting to fulfil the full stack developer skillset I am missing a front-end framework and React suits this spot due to its popularity and capabilities.

Having existing Javascript knowledge with jQuery and some Vue.js React doesn’t feel too strange for me when i got started with it.

I am well versed in the Backend and now know Tailwind CSS, so using React with Inertia, TailwindCSS and Laravel seems solid.

State management

State management refers to the state or rendering of the DOM from the data it possesses. When this data changes rendering will instantly occur. As React is declarative you only need to provide the data and the UI will update.

This quote from the React docs explains it very well

In React, you don’t directly manipulate the UI—meaning you don’t enable, disable, show, or hide components directly. Instead, you declare what you want to show, and React figures out how to update the UI.

The JSX format

JSX is a syntax extension to Javascript and allows you to write React elements with the full power of Javascript. The best part of using JSX is you mix in HTML and Javascript as one, meaning you dont need separate files.

An example of JSX:

function formatName(user) {
  return user.firstName + ' ' + user.lastName;
}

const user = {
  firstName: 'Michael',
  lastName: 'Jordan'
};

const element = (
  <h1>Hello, {formatName(user)}!</h1>
);

Using a modern smart IDE like JetBrins PHPstorm/Webstorm makes writing in JSX format a breeze with suggestions and auto-complete.

Component based

React is very big on components and component hierarchy. This makes development faster and less repetitive, passing the state or data through components keeps the code base clean.

There are many great, comprehensive component frameworks for React that will speed up development greatly.

Libraries

Readily available for use with React is a massive assortment of libraries to expand and speed up your development. Importing these libraries are incredibly easy, more so if using a modern IDE.

React icons is an example of this, where you get access to popular icons.

Share

Recent Posts

Kennington reservoir drained drone images

A drained and empty Kennington reservoir images from a drone in early July 2024. The…

1 year ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

1 year ago

FTP getting array of file details such as size using PHP

Using FTP and PHP to get an array of file details such as size and…

2 years ago

Creating Laravel form requests

Creating and using Laravel form requests to create cleaner code, separation and reusability for your…

2 years ago

Improving the default Laravel login and register views

Improving the default Laravel login and register views in such a simple manner but making…

2 years ago

Laravel validation for checking if value exists in the database

Laravel validation for checking if a field value exists in the database. The validation rule…

2 years ago