Author: saqibkhan

  • What are the components in React?

    Components are the building blocks of any React application, and a single app usually consists of multiple components. A component is essentially a piece of the user interface. It splits the user interface into independent, reusable parts that can be processed separately.

    There are two types of components in React:

    react-component
    • Functional Components: These types of components have no state of their own and only contain render methods, and therefore are also called stateless components. They may derive data from other components as props (properties).
    function Greeting(props) {  return <h1>Welcome to {props.name}</h1>;}
    • Class Components: These types of components can hold and manage their own state and have a separate render method to return JSX on the screen. They are also called Stateful components as they can have a state.
    class Greeting extends React.Component {  render() {    return <h1>Welcome to {this.props.name}</h1>;  }}
  • How is React different from Angular?

    AngularReact
    AuthorGoogleFacebook
    ArchitectureComplete MVCView layer of MVC
    DOMReal DOMVirtual DOM
    Data-BindingBi-directionalUni-directional
    RenderingClient-SideServer-Side
    PerformanceComparatively slowFaster due to Virtual DOM
  • How is React different from React Native?

    ReactReact Native
    Release20132015
    PlatformWebMobile – Android, iOS
    HTMLYesNo
    CSSYesNo
    PrerequisitesJavaScript, HTML, CSSReact.js
  • What is an arrow function and how is it used in React?

    • An arrow function is a short way of writing a function to React.
    • It is unnecessary to bind ‘this’ inside the constructor when using an arrow function. This prevents bugs caused by the use of ‘this’ in React callbacks.
    arrow
  • How do you write comments in React?

    There are basically two ways in which we can write comments:

    • Single-line comments
    return
    • Multi-line comments
    multi-line
  • What are forms in React?

    React employs forms to enable users to interact with web applications.

    • Using forms, users can interact with the application and enter the required information whenever needed. Form contain certain elements, such as text fields, buttons, checkboxes, radio buttons, etc
    • Forms are used for many different tasks such as user authentication, searching, filtering, indexing, etc
  •  Why is there a need for using keys in Lists?

    Keys are very important in lists for the following reasons:

    • A key is a unique identifier and it is used to identify which items have changed, been updated or deleted from the lists
    • It also helps to determine which components need to be re-rendered instead of re-rendering all the components every time. Therefore, it increases performance, as only the updated components are re-rendered
  •  Explain how lists work in React

    • We create lists in React as we do in regular JavaScript. Lists display data in an ordered format
    • The traversal of lists is done using the map() function
    const
  •  What are synthetic events in React?

    • Synthetic events combine the response of different browser’s native events into one API, ensuring that the events are consistent across different browsers.
    • The application is consistent regardless of the browser it is running in. Here, preventDefault is a synthetic event.
  • How do you create an event in React?

    A React event can be created by doing the following:

    Question 9