Posts

Showing posts from January, 2022

Understanding and Implementing Schemas in Python

Understanding and Implementing Schemas in Python Introduction In the world of programming, particularly in the context of data management and validation, schemas play a vital role. A schema is essentially a blueprint or a predefined structure that defines the expected format, data types, and constraints for a given data entity. In this blog, we will delve into the concept of schemas in Python, exploring what they are, why they are important, and how you can implement them in your projects. What is a Schema? A schema serves as a contract between different components of a system, ensuring that data is consistent, valid, and well-structured. It defines the rules for how data should be organized, what fields it should contain, and what types of values those fields can hold. In essence, a schema acts as a set of rules that data must adhere to in order to be considered valid. Why Are Schemas Important? Data Validation: Schemas provide a way to validate incoming data. When data is received o

How to fetch data from an API using fetch() method in React Js

Image
How to fetch data from an API using fetch() method in React Js? Now a day, we can't imagine web application without API so one of the basic requirement of any web application is to communicate with servers through HTTP protocol. This can be easily done using Fetch and Axios .  In this post, we are mainly focusing on Fetch. The Fetch API provides a fetch() method defined on the window object. The fetch method has one mandatory argument i.e., URL of the resource to be fetched. This method returns promise object that can be used to retrieve response of the request.  There are following limitations of Fetch API: a) Fetch does not allows cancelling request and request timeout. b) Fetch does not provide a way to intercept HTTP requests. c) Fetch has no url in request object. d) No installation is required. e) Fetch does not have XSRF protection. f) Fetch uses the body property. g) Fetch is a two step process when handling JSON data, first - to make actual request. second - to call json()

Create a Shopping Item App using React Js and Xstate

Image
Create a Shopping Item App using React Js and Xstate ( state management )  In this post, we will create a shopping item app using React js and Xstate. Generally, we use redux for state management but in this application, I am going to show you state management with the help of Xstate. Shopping Item App using React Js and Xstate Dependency:   npm install xstate @xstate/react Folder Structure: Sample Code: A) index.js import   React   from   "react" ; import   ReactDOM   from   "react-dom" ; import   App   from   "./App" ; ReactDOM . render ( < App   /> ,  document . getElementById ( "root" )); B) App.js import   React   from   'react' ; import   Product   from   './Product/Product' ; import   './style.css' ; import  { ShoppingContext ,  ShoppingMachine }  from   './State/index' import  {  useMachine  }  from   '@xstate/react' ; export   default   function   App () {    const  [ currentStates ,  sendToM

Pass data from child component to its parent component in React Js

Image
Pass data from child component to its parent component in React Js In this post, we will learn about how to pass data from child component to its parent component in React js. We need to do following steps to pass/send data from child component to parent component: a) In the parent component, create a callback function. This callback function is useful to retrieve the data from the child component. b) Pass the callback function to the child as a props from the parent component. c) The child component calls the parent callback function using props and sends the data to the parent component. Send data from child component to its parent component Sample Code: A) index.js import   React   from   "react" ; import   ReactDOM   from   "react-dom" ; import   App   from   "./App" ; ReactDOM . render ( < App   /> ,  document . getElementById ( "root" )); B) App.js import   React , {  useState  }  from   'react' ; import   './style.css'

Localization in React Js

Image
Localization in React Js using react-localization package. In this post, we will learn about Localization in React Js. Now a day, Localization is very important and basic requirement in every web based application. Following source code will help you, creating a multilingual Web application in React Js. Note: Use Double Click for Radio Boxes. Localization in React Js Installation: npm install --save react-localization Folder Structure: Sample Code A) index.js import   React   from   "react" ; import   ReactDOM   from   "react-dom" ; import   App   from   "./App" ; ReactDOM . render ( < App   /> ,  document . getElementById ( "root" )); B) App.js ( Class Component ) import   React , {  Component  }  from   'react' ; import   labels   from   './Local/localize' ; import   './style.css' ; class   App   extends   Component  {    constructor ( props ) {      super ( props );      this . state  = {        language:   '