Posts

Router and navbar in React tut 16

Router in React To use router concept in React , first you have to  perform following steps. 1st : TO install Router  $ npm install  --save react-router-dom 2nd :  import following in index.js file import  { BrowserRouter }  from   "react-router-dom" 3nd :  Use of BrowserRouter in index.js file ReactDOM . render (    < BrowserRouter > < App /> </ BrowserRouter >   ,    document . getElementById ( 'root' ) ); 4th : Router.jsx , where we give path of pages import   React   from   'react' import  { Route  ,  Switch }  from   "react-router-dom" import   Contact   from   './RContact' import   About   from   './RAbout' import   ErrorMsg   from   './ErrorMsg' import   Navbar   from   './Navbar' let   Service  = () => {    return ( < >     < h1 > This...

React API call using axios and useEffect tut 15

React API call using  axios and useEffect Axios will fetch the data from react api  syntax :  asynx function functionName(){ const  res = await axios.get("url"); } example :   React API Call to Get Pokemon JSON Data using Axios and useEffect in ReactJS import   React , {  useState ,  useEffect  }  from   'react' ; import   Axios   from   'axios' ; let   AxiosPokemon  = ()  =>  {      let  [ num , setNum ] =  useState ();      let  [ name , setName ] =  useState ( "" );      let  [ move , setMove ] =  useState ();      useEffect (() => {          async   function   getData (){              const   res  =  await   Axios . get ( `...

Changing the Title of Website on Button Click in React Hook tut 14

Changing the Title  of Website on Button Click in React Hook filename : ChgTitle.jsx import   React , {  useState ,  useEffect  }  from   'react' ; let   ChgTitle  = ()  =>  {      let  [ num ,  setNum ] =  useState ( 0 );      useEffect (() => {          document . title  =  `Clicked me ðŸ˜Ž ${ num }` ;     })      return  (          < >              < center >                  < br   />< br   />                  < button   onClick = { ()  => ...

useEffect() in React tut 13

useEffect() in React // Here We are learning the useEffect concept in Hook // useEffect call it's callback function to perform some operation after render // In Real example , we are performing some operation like after clicking on button // number will be increment , so if we want that after executing this operation some another // operation will execute like show some message then this time we can use useEffect concept as follow // note : useEffect will show message (execute operation) even if number will increment or not (onClick operation will execute or not ) //Hope you will understand , let's Use filename: UseEffect.jsx import   React , {  useState ,  useEffect  }  from   'react' ; // Here We are learning the useEffect concept in Hook  // useEffect call it's callback function to perform some operation after render  // In Real...

useContext() in React tut 12

useContext() in React We can use useContext to receive the data directly from context provider instead of using complex context consumer  file hierchy :  ContextAPI.jsx ==> ComA.jsx ==> comB.jsx    we are sending data directly from ContextAPI.jsx to ComB.jsx. File : ContextAPI.jsx import   React , {  createContext  }  from   'react' ; import   ComA   from   './ComA' ; var   FilmName  =  createContext (); var   Earned  =  createContext (); let   ContextAPI  = ()  =>  {      return  (          < >              < FilmName.Provider   value = { 'GolMaal film' } >                  < Earned.Provider   value = { '25 crore' } > ...

Context API in React Tut 11

Context API in React The  Context API  is a component structure provided by the React framework, which enables us to share specific forms of data across all levels of the application.    A.jsx  ==> B.jsx ==> C.jsx if we want to send the data from A to C , then we have to pass it through B via concept of props , but if we want to send the data directly from A to C .  So for that we need to use concept of context API . Practical of this concept as follow :  File hierachy is as Follow :               ContextAPI.jsx ==> ComA.jsx ==> ComB.jsx ==>ComC.jsx file :  ContextAPI.jsx   import   React , {  createContext  }  from   'react' ; import   ComA   from   './ComA' ; var   FilmName  =  createContext (); let   ContextAPI  = ()  =>  {      return  (       ...

vector in C++

               #vector in C++ code : #include<iostream> #include<vector>  // vector header file #include<algorithm> // This header file contain sort method using namespace std; int main() { vector <int> v; // Declaration of vector int v.push_back(10); v.push_back(30); v.push_back(20);   // To insert element into vector v.push_back(90); v.push_back(50); int size = v.size(); // To get size of Vector cout<<"Size of Vector : "<<size<<endl; // sort the element of vector sort(v.begin(),v.end()); // TO sort we have to pass two parameter                           //which are first element and second element                           v.pop_back();  // To Delete Elements from Array v.pop_back(); size = v.size(); // To get size ...