Shyam Hande has Published 72 Articles

Making http request in React.js

Shyam Hande

Shyam Hande

Updated on 04-Sep-2019 15:01:10

3K+ Views

In a typical web application, client makes a http request through browser and server sends html page in the response with data.But in a single page application (SPA), we have only one page and whenever client makes http request to server it generally responses with a json/xml formatted data.For making ... Read More

React.js stateless vs stateful

Shyam Hande

Shyam Hande

Updated on 04-Sep-2019 14:49:37

4K+ Views

Understand the difference in stateless and stateful react componentsIn state management post, we learned how we can handle state in react if something is changed.Stateless components are simple functional component without having a local state but remember there is a hook in react to add state behavior in functional component ... Read More

Using proptypes in React.js

Shyam Hande

Shyam Hande

Updated on 04-Sep-2019 14:44:55

165 Views

Use of proptypes ensures the type safety of receiving props on the components and also helps in making correct calculation.Example − If we are receiving name as string and age as number then it should be received with the same type. If we receive age in string then it can result ... Read More

Context api in React.js

Shyam Hande

Shyam Hande

Updated on 04-Sep-2019 14:41:40

776 Views

The React context api is safe to use in production with the version 16.3 or latest. The reason for adding context api is to avoid the passing of props if there is a chain of children components.Without the use of context api, we have to pass the props through all ... Read More

Why need build workflow in React.js

Shyam Hande

Shyam Hande

Updated on 04-Sep-2019 14:34:28

636 Views

BUILDING A WORK-FLOW HELPS IN DOING BELOW THINGSIt optimizes codeUsing next-gen JavaScript (ES6)Its a standard way for single/multiple page appsProductive approachEasy integration of dependencies with NPM or YarnUse of bundler like web-pack for easier modular code and shipping codePre compiler like BabelWe can use a local development server to test ... Read More

Using useState hook in React.js

Shyam Hande

Shyam Hande

Updated on 04-Sep-2019 14:24:52

486 Views

Hooks allows the functional component in react to get the features available in class based component in make them more powerful.useState we will import from react. Import {useState} from ‘react’; This helps us in creating local state variables for functional component and provides method to update that variable.State in class ... Read More

Using useEffect() in React.js functional component

Shyam Hande

Shyam Hande

Updated on 04-Sep-2019 14:22:45

3K+ Views

The React hook useEffect helps in adding componentDidUpdate and componentDidMount combined lifecycle in React’s functional component.So far we know we can add lifecycle methods in stateful component only.To use it, we will need to import it from react −import React, { useEffect } from ‘react’; const tutorials=(props)=>{    useEffect( ()=>{ ... Read More

Using useContext in React.js

Shyam Hande

Shyam Hande

Updated on 04-Sep-2019 14:20:48

855 Views

useContext hook allows passing data to children elements without using redux.useContext is a named export in react so we can importin functional components like below −import {useContext} from ‘react’;It’s an easy alternative to Redux if we just need to pass the data to the children elements.Simple example creating a contextimport ... Read More

Promises Callbacks And Async/Await

Shyam Hande

Shyam Hande

Updated on 04-Sep-2019 14:03:41

762 Views

First we have to understand two main conceptsSynchronous programmingAsynchronous programmingSYNCHRONOUS PROGRAMMINGIt waits for each statement to complete its execution before going to next statement.This approach can slow down application process if statements are not dependent on each other but still they are waiting for execution as they are in queue.ASYNCHRONOUS ... Read More

Styling in React.js

Shyam Hande

Shyam Hande

Updated on 04-Sep-2019 13:50:26

495 Views

Styling in React.js can be done in below two wayscss style sheetsinline styleLet’s see CSS style sheets firstWe have App.js file as shown below −import React, {Component} from 'react'; import './App.css'; class App extends Component {    render(){       return (               ... Read More

Advertisements