reading-notes

View the Project on GitHub Abu-laban/reading-notes

Introduction to React and Components

Component-Based Architecture

The primary objective of component-based architecture is to ensure component reusability. A component encapsulates functionality and behaviors of a software element into a reusable and self-deployable binary unit. There are many standard component frameworks such as COM/DCOM, JavaBean, EJB, CORBA, .NET, web services, and grid services.

Component-oriented software design has many advantages over the traditional object-oriented approaches such as −

  • Reduced time in market and the development cost by reusing existing components.
  • Increased reliability with the reuse of the existing components.

What is a Component?

A component is a modular, portable, replaceable, and reusable set of well-defined functionality that encapsulates its implementation and exporting it as a higher-level interface.

Characteristics of Components

  1. Reusability
  Components are usually designed to be reused in different situations in different applications. However, some components may be designed for a specific task.
  1. Replaceable
  Components may be freely substituted with other similar components.
  1. Not context specific
  Components are designed to operate in different environments and contexts.
  1. Extensible
  A component can be extended from existing components to provide new behavior.
  1. Encapsulated
   A component depicts the interfaces, which allow the caller to use its functionality, and do not expose details of the internal processes or any internal variables or state.
  1. Independent
  Components are designed to have minimal dependencies on other components.

Advantages

What is “Props” and how to use it in React?

What is Props?

React is a component-based library which divides the UI into little reusable pieces. In some cases, those components need to communicate (send data to each other) and the way to pass data between components is by using props.

“Props” is a special keyword in React, which stands for properties and is being used for passing data from one component to another.

But the important part here is that data with props are being passed in a uni-directional flow. (one way from parent to child)

Using Props in React

  1. Firstly, define an attribute and its value(data)
  2. Then pass it to child component(s) by using Props
  3. Finally, render the Props Data

    You can also learn how to use Props by watching my tutorial video below:

IMAGE ALT TEXT HERE

    Props can only be passed to components in one-way (parent to child)