Technical Articles

Tech Articles from your friends at Oracle and the developer community.

Topics
                        Topics

                        What is React JS?

                        There are more than 200 programming languages developers use all over the world. JavaScript has been among the most popular for more than 20 years because of its ease of use and extensive frameworks and libraries available.

                        JavaScript frameworks and libraries make applications and website development easier, making interactive web pages quicker and more efficient. Both libraries and frameworks are reusable code someone else wrote, and you are adapting for your own use.

                        The technical difference between the two developer tools is that with a library, you choose where and when you want to plug in the code. With a framework, you have limited choices. You plug in your code wherever it allows you to.

                        React.js is one of the many JavaScript libraries. Read on to discover what is React.js and what is React used for.

                        React.js definition

                        Before explaining what React Javascript is, it's important to understand the definition of JavaScript.

                        JavaScript is a programming language that allows the implementation of complex features in web design. JavaScript is a growing and evolving language that has innumerable uses.

                        If a web page does anything other than display static information and require a UI (User Interface) or includes animated graphics or photo slideshows, you can be guaranteed JavaScript is probably part of the coding.

                        To use JavaScript, you will need some basic understanding of HTML and CSS. HTML structures the web content with headers, paragraphs, tables, and images. CSS controls color, font, and animation.

                        Should you need UI or other animation, JavaScript will be part of these layered web technologies. JavaScript has a wealth of libraries that contain functions or lines of code for performing specific tasks on a web page that requires input from a user.

                        React is a front-end UI JavaScript library that requires input from a user, which will drive other processes smoothly. Using React Js, developers need less time to develop an interactive web page and has much fewer opportunities for errors and bugs.

                        Why Use React?

                        Facebook created React in 2011 but is now widely used by other companies. In fact, it has eclipsed all other front-end development libraries.

                        Using React, it is much easier to create dynamic web applications because you require much less coding. The Virtual DOM (Document Object Model) updates only components that need updating.

                        Data flows in one direction only, allowing web developers to nest secondary components (or child components) within primary ones (or parent components). Errors are thereby easier to debug and code is more stable.

                        If you know how to use HTML and JavaScript, the learning curve for beginners is much smaller. You can also use React to develop web and mobile apps. The mobile apps are developed using React Native, a spinoff from ReactJs, which Facebook developed in 2015.

                        Facebook recently released a Chrome extension that allows easy debugging of React applications.
                        These are only a few of the reasons why so many developers choose to do front-end web development with React.

                        Features of React JavaScript

                        The powerful features described in this section have made React a robust contender in the JavaScript universe. It performs quickly and efficiently and allows developers more flexibility with its use of third-party libraries.

                        React Components

                        React is centered around the development of components that you can reuse over and over again. A component is like a function or building block of an application. All apps consist of multiple components.

                        React splits a UI into reusable, independent parts that can be processed separately. Components can be built within other components, the parent component being the initiator and the child component receiving the information from the parent.

                        JSX

                        All basic web pages are created as HTML documents. A web browser reads these documents and displays them on the screen of your device. This is done by creating a Document Object Model (DOM) or tree of how this web page is arranged.

                        Dynamic content is added to this web page by including modifications using a language like JavaScript.

                        JSX (JavaScript eXtension) is a feature of React that facilitates the modification of a DOM using HTML code. It is also compatible with all web browsers.

                        Virtual DOM

                        One of the powerful features of React is the Virtual DOM. As mentioned before, your web page uses HTML to update its DOM whenever a user interacts with the page.

                        Under normal circumstances, this requires the reloading of the entire DOM with every interaction. This takes time and computing power.

                        React's Virtual DOM, using JSX, will create a copy of the page's DOM, and React JS uses this copy to determine what parts of the actual DOM need to change. This way, the entire web page does not need to reload, just the relevant section or sections.

                        States and Hooks

                        Using React JS, you create interactive experiences for users by deciding which components will be static and mutable. This is called a React state. For a data component to be considered a state, it has to change over time and can't remain permanently static.

                        Every time a state changes, the component will re-render. State changes happen based on user action or system-generated events.

                        React hooks are features that connect the internal logic between components. It will intercept function calls or messages passing between components based on a set of logic commands. It can also halt rewriting a component or allow a modification of a component.

                        Props

                        The term 'props' is short-form for properties. It's a built-in object in React which stores a tag's attribute (similar to HTML attributes). It's a way to pass data from a parent component to a child component in the same way HTML passes attributes in a function.

                        Props get unwieldy when the parent component passes a tag through several child components to a final destination component. You can manage this more efficiently using a spread operator.

                        A spread operator will expand iterables such as strings and arrays into individual elements. This facilitates the movement of props between components.

                        Debugging

                        Bugs and errors are generally avoided in React because of the component feature. They will still appear, but by the very nature of the structure of this JavaScript library, they are quite easy to detect. The large developer community also makes detection very easy.

                        Facebook also created a nifty browser extension for Chrome that adds a React tab in the developer tools option. This tab makes inspection of React components quick and easy.

                        Comparing React JS with Angular

                        Both of these developer tools use JavaScript differently and have different uses and advantages. Both React and Angular are component-based as well. One of the key points is that React is a JavaScript library, and Angular is a JavaScript structural framework./p>

                        How to compile and run GitHub projects?

                        For most projects, you'll need an integrated development environment. Each repository should have a README file to advise how to build/compile the project.

                        Sometimes the main repository has a “Releases” tab which takes you to a list of releases where the project is already compiled, which is by far the easiest way to compile a project.

                        Key Uses, Features, and Advantages of React

                        • You can use third-party libraries
                        • Saves time
                        • Simple to learn
                        • Supported by Facebook
                        • Fast performance due to use of Virtual DOM
                        • One-directional data-binding means that changing a UI element will not change the model state
                        • Structured using components
                        • HTML-like syntax allows templates to be shared
                        • Uses JavaScript
                        • You are in charge of the flow of the application
                        • When updates are done, code has to be rewritten
                        • Debugging is done using a set of tools to perform different types of bug testing
                        • Used by Facebook, Instagram, WhatsApp, Uber, Netflix, Airbnb, and Dropbox

                        Key Uses, Features, and Advantages of Angular

                        • Clean code development
                        • Permits more feature-rich and complex mobile app development
                        • Material Design-like Interface
                        • Based on MVC (Model View Controller)
                        • Has numerous ready-to-use elements
                        • Difficult to learn
                        • Uses TypeScript
                        • Two-way data-binding means that changing a UI element will also change the corresponding model's state
                        • Clean, crisp coding
                        • When updates are done, the two-way data flow does the update of the components for you
                        • A single tool is required to debug a complete project
                        • Used by General Motors, Upwork, Nike, Forbes, Google, and Sony

                        What's the Purpose of Using React JS?

                        Essentially, the React JS library is best to use if you need fast performance and personalized solutions. Marketers know that slow-reacting apps get deleted quickly, so speed is essential.

                        You would turn to React if you want to create components that can be shared and reused. Because of the one-direction data flow, the code is more stable as well.

                        What's the Purpose of Using Angular?

                        Angular is best if you want a ready-to-use solution that is feature-rich, and speed is not a priortiy. The two-way data binding requires less developer intervention, which means less manipulation of the DOM. Because it is a framework, you also need to write less code.

                        Getting Started With React

                        After exploring what React JS is and comparing it to other developer tools like Angular, you can make your decision. Afterwards, you’ll be ready to launch into learning how to use React and create your first component-based app using this popular developer tool.

                        Get started today by applying your JavaScript and HTML knowledge to complete a React Tutorial.

                        Latest content

                        Explore and discover our latest tutorials

                        Serverless functions

                        Serverless functions are part of an evolution in cloud computing that has helped free organizations from many of the constraints of managing infrastructure and resources. 

                        What is a blockchain?

                        In broad terms, a blockchain is an immutable transaction ledger, maintained within a distributed peer-to-peer (p2p) network of nodes. In essence, blockchains serve as a decentralized way to store information.

                        OCI CLI

                        The CLI is a small-footprint tool that you can use on its own or with the Console to complete Oracle Cloud Infrastructure tasks. The CLI provides the same core functionality as the Console, plus additional commands.