Posts

Showing posts from August, 2022

React toolkit

 https://redux-toolkit.js.org/tutorials/quick-start

React query

optional chaining[ >data is fetched in data varible.. in render:--data?data.map()... ]  useEffect hook:data fetching and  use state hook : to manintain componet state like  loading, error or resulting data.. [data needed throughout the app]: state management library[redux]   state management are not great for working with asynchronous or server state.  client state: presisted in your app memory and accessing or updating it  synchronou server state persisted remotely and requires asynchronous api's for fetching or  updating..  has shared ownership caching deduping multiple request for the same data, updating state data in the background performance optimization etc. project setup: >npx react app reactquerydemo Note:-- json-server[get and post] 1.make db.json 2.add  "server-json":"json.server --watch db.json --port 4000" react-router-dom:- Traditional super hero   Rq Super hero Fetch data:-useeffect() and usestate() ...............

countdowntimerreact

  javascript - Implementing a countdown timer in React with Hooks - Stack Overflow setInterval in React Components Using Hooks - Upmostly

CustomHooks

1:-- import   React   from   'react' import  {  useEffect  }  from   'react' export   default   function   UseCount ( count ) {      useEffect (() => {          console . log ( 'good morning' );                   document . title = "facebook.com"          if ( count > 0 ){            document . title = `facebook.com ${ count } ` ;         }           },[ count ])          } import  {  ChangeCircle  }  from   '@mui/icons-material' ; import   React ,{ useState , useEffect }  from   'react' import   UseCount   from ...

nodejwt

  const   express = require ( 'express' ); const   router = express (); const   user = require ( '../Models/clientProfile' ); const   bodyParser = require ( 'body-parser' ); const   jsonParser = bodyParser . json (); const   jwt = require ( 'jsonwebtoken' ); /*const crypto=require('crypto'); const key='pass'; const algo='aes256';*/ const   bcrypt = require ( 'bcrypt' ); //get api:-- router . get ( '/' ,( req , res , next ) => { res . send ( "hello api ji" ); }) router . post ( '/' , jsonParser , function ( req , res , next ){      /*const cipher=crypto.createCipher(algo,key);     const encypass=cipher.update(req.body.password,'utf-8','hex')     +cipher.final('hex');      console.log(encypass);*/      bcrypt . hash ( req . body . password , 10 , ( err , hash ) => {      ...

react fetchasyn

  import   React  ,{ useState , useEffect } from   'react' import   axios   from   'axios' export   default   function   Fetch1 () {      const  [ state , setState ]= useState ([]);          const  [ loading , setLoading ]= useState ( true );      useEffect (() => {          async   function   getdata (){                        try {                  setLoading ( false );                     const   res =  await   axios . get ( 'https://jsonplaceholder.typicode.com/posts' );     ...