React JS

React JS

React is a powerful JavaScript library for building dynamic and interactive user interfaces (UIs). It is developed by Facebook. React is known for its component-based architecture which allows you to create reusable UI elements, making complex web applications easier to manage and maintain. React is used to build single-page applications.

React components:

React can change how you think about the designs you look at and the apps you build. When you build a user interface with React, you will first break it apart into pieces called components. Then, you will describe the different visual states for each of your components. Finally, you will connect your components together so that the data flows through them.

  • Every component receives a list of attributes, just like HTML elements. In React, this list is called props. With a function component, you can name it anything though.
  • We weirdly wrote what looks like HTML in the returned output of the Button function component above. This is neither JavaScript nor HTML, and it’s not even React.js. But, it’s so popular that it became the default in React applications. It’s called JSX and it’s a JavaScript extension. JSX is also a compromise! Go ahead and try and return any other HTML element inside the function above and see how they are all supported (for example, return a text input element).

We can use JavaScript expressions anywhere in JSX:

Inside a JSX section, you can use any JavaScript expression within a pair of curly braces. Any JavaScript expression can go inside those curly braces. This is equivalent to the ${} interpolation syntax in JavaScript template literal. This is the only constraint inside JSX: only expressions. So, for example, you can’t use a regular if statement, but a ternary expression is ok.

JavaScript variables are also expressions, so when the component receives a list of props (the Random Value component didn’t, props are optional), you can use these props inside curly braces. We did this in the Button component above JavaScript objects are also expressions. Sometimes we use a JavaScript object inside curly braces, which makes it look like double curly braces, but it’s really just an object inside curly braces. One use case of that is to pass a CSS style object to the special style attribute in React.



To view or add a comment, sign in

More articles by sangeetha M

  • 3D Printing: Transforming Industries and Innovation

    3D printing, also known as additive manufacturing, has rapidly evolved from a niche technology into a transformative…

  • Role of Front-End Development in Shaping UX

    When we think of UX, we often focus on design aesthetics, ease of navigation, or the visual elements that captivate…

  • SPACE TECHNOLOGY

    Space technology encompasses a broad range of tools, systems, and techniques designed for exploration, communication…

  • 5th GENERATION

    What is 5G technology? 5G technology has a theoretical peak speed of 20 Gbps, while the peak speed of 4G is only 1…

    1 Comment
  • UI/UX into design thinking

    UI/UX is a human-centered approach to creating content that is both usable and engaging for users. It involves…

  • FOREIGN LANGUAGE

    WHY JAPANESE LANGUAGE?? I get this question all the time. If you’re thinking the same, you may be curious to know the…

Others also viewed

Explore content categories