DEV Community

Sanat Kumar Mohanta
Sanat Kumar Mohanta

Posted on

JavaScript Week-4 Day-4

context API: The Context API is a React structure that enables you to exchange unique details and assists in solving prop-drilling from all levels of your application.

JSX : JSX stands for JavaScript XML. It is simply a syntax extension of JavaScript. It allows us to directly write HTML in React (within JavaScript code)

HOOKS: Hooks are JavaScript functions, but they impose two additional rules:

Only call Hooks at the top level. Don't call Hooks inside loops, conditions, or nested functions.
Only call Hooks from React function components. Don't call Hooks from regular JavaScript functions.

custom hooks: Custom Hook is a JavaScript function which we create by ourselves when we want to share logic between other JavaScript functions. It allows you to reuse some piece of code in several parts of your app.

State-props: Props are used to pass data, whereas state is for managing data. Data from props is read-only, and cannot be modified by a component that is receiving it from outside. State data can be modified by its own component.

What is the use of PropTypes?

PropTypes are a mechanism to ensure that components use the correct data type and pass the right data, and that components use the right type of props, and that receiving components receive the right type of props.

Performance Optimization Techniques for React Apps

  1. Using Immutable Data Structures.
  2. Function/Stateless Components and React.
  3. Multiple Chunk Files.
  4. Use React.
  5. Avoid Inline Function Definition in the Render Function.
  6. Throttling and Debouncing Event Action in JavaScript.
  7. Avoid using Index as Key for map.

Scope: Scope determines the accessibility of variables to JavaScript. The two types of scope are local and global:

Global variables are those declared outside of a block

Local variables are those declared insides of a block

What is hoisting in JavaScript?

In JavaScript, Hoisting is the default behavior of moving all the declarations at the top of the scope before code execution.

Top comments (0)