Sunday, 7 April 2024

React Questions and awnsers

 Type of Components

Class(Statefull Components) - Error Handling mange session(Error Boundary), Life Cycle

Functional - Module Way -I will be little faster when use function (React hook , After react 16 Version)


Life Cycle

Mounting,Updating and Unmounting

Mounting

    constructor()

    getDerivedStateFromProps()

    render()

    componentDidMount()

Updating

    getDerivedStateFromProps()

    shouldComponentUpdate()

    render()

    getSnapshotBeforeUpdate()

    componentDidUpdate()

Unmounting

    componentWillUnmount()

React Hook

UseState,UseEffect,UseContext,UseRef,UseReducer,UseCallBack,UseMemo,Custom Hooks

UseState

useState accepts an initial state and returns two values:

The current state.

A function that updates the state.

UseEffect

useEffect runs on every render. That means that when the count changes, a render happens, which then triggers another effect.

API Using in React

Axios - Json by default

Axios has the ability to inercept HTTP Request

Axioshas built-in support for download progress

Fetch

Fetch by default ,Do not provide a way to intercept request

Fetch does not support uload progress

How to use transfer the one comp to another

Parent to child - using props

child to parent - using call back function

No comments:

Post a Comment