Reactjs

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What is the difference between Element and Component?

An Element is a plain object describing what you want to appear on the screen in terms of the DOM nodes or other components. Once an element is created, it is never mutated. Whereas a component can be declared in several different ways. It can be a class with a render() method or it can be defined as a function. In either case, it takes props as an input, and returns a JSX tree as the output:

What is the difference between state and props?

Both props and state are plain JavaScript objects. While both of them hold information that influences the output of render, they are different in their functionality with respect to component. Props get passed to the component similar to function parameters whereas state is managed within the component similar to variables declared within a function.

When to use a Class Component over a Function Component?

If the component needs state or lifecycle methods then use class component otherwise use function component. However, from React 16.8 with the addition of Hooks, you could use state , lifecycle methods and other features that were only available in class component right in your function component. *So, it is always recommended to use Function components, unless you need a React functionality whose Function component equivalent is not present yet, like Error Boundaries *

Why should we not update the state directly?

If you try to update the state directly then it won't re-render the component. Instead use setState() method. It schedules an update to a component's state object. When state changes, the component responds by re-rendering.

What is JSX?

JSX is a XML-like syntax extension to ECMAScript (the acronym stands for JavaScript XML). Basically it just provides syntactic sugar for the React.createElement() function, giving us expressiveness of JavaScript along with HTML like template syntax.

What is ReactJS?

React is an open-source front-end JavaScript library that is used for building user interfaces, especially for single-page applications.

What is state in React?

State of a component is an object that holds some information that may change over the lifetime of the component.

What are the major features of React?

The major features of React are: It uses VirtualDOM instead of RealDOM considering that RealDOM manipulations are expensive. Supports server-side rendering. Follows Unidirectional data flow or data binding. Uses reusable/composable UI components to develop the view.


Kaugnay na mga set ng pag-aaral

6 DIFFERENT BASIC SWIMMING STYLE AND STROKE'S

View Set

Biochemsistry, Histology, Clinical Skills Questions

View Set

BUS-107 Contemporary Business Law Ch. 26

View Set

Prep U for Brunner and Suddarth's Textbook of Medical Surgical Nursing, 13th Edition Chapter 36: Management of Patients With Immunodeficiency Disorders

View Set