|
| 1 | +React Lists |
| 2 | + |
| 3 | +List are used to display data in an ordered format and mainly used to display |
| 4 | +menus on website. |
| 5 | + |
| 6 | +In React ,Lists can be created in similar way as we create Lists in javascript. |
| 7 | + |
| 8 | +The map() function is used for traversing the lists. |
| 9 | + |
| 10 | +------------------------------------------------ |
| 11 | +React Keys |
| 12 | +When creating a list in JSX,React may show you an error and ask for a key. |
| 13 | + |
| 14 | +A key is a special string attribute you need to include when creating list of element. |
| 15 | + |
| 16 | +---------------------------------------------------------------- |
| 17 | + |
| 18 | +Phase of Component:- |
| 19 | + |
| 20 | +Creation |
| 21 | +Updating |
| 22 | +Deletion |
| 23 | + |
| 24 | +lifecycle hooks in functional based component |
| 25 | +or |
| 26 | +in class based component lifecycle method |
| 27 | + |
| 28 | +Phase of component: |
| 29 | +Mounting |
| 30 | + Mounting is the process of creating an element and inserting it in a DOM tree. |
| 31 | + Mounting has 3 methods |
| 32 | + constructor() |
| 33 | + render() |
| 34 | + componentDidMount() |
| 35 | +Updating |
| 36 | + Updating is the process of changing state or props of component and update changes |
| 37 | + componentDidUpdate() |
| 38 | +Unmounting |
| 39 | + Unmounting is the process of removing component from the DOM |
| 40 | + comonentWillUnmount |
| 41 | +-------------------------------------------------------------------------------------------------------------- |
| 42 | +Hooks |
| 43 | + -Defined |
| 44 | + -Why Hooks |
| 45 | + -No breaking API changes |
| 46 | + -Hooks API |
| 47 | + -useState |
| 48 | + -useEffect |
| 49 | + -Rules of Hooks |
| 50 | + |
| 51 | +Hooks allows us to use state and other React features without writing class. |
| 52 | + |
| 53 | +When to use a Hook: |
| 54 | + |
| 55 | +Rules of Hooks |
| 56 | +1.Only call Hook at the top level |
| 57 | + Do not call Hooks inside loops,conditions,or nested functions.Hooks should always be used at the |
| 58 | + top level of the React function. |
| 59 | +2.Only call Hook from React functions |
| 60 | + |
| 61 | +setState() and states |
| 62 | + |
| 63 | +Built in Hook |
| 64 | + -useState |
| 65 | + To use state in functional component |
| 66 | + -useEffect |
| 67 | + is a hook for encapsulating code that has 'side effects'.The function passed to useEffect will run |
| 68 | + after the render is commited to the screen. |
| 69 | + |
| 70 | +https://react.dev/reference/react/useEffect |
| 71 | + |
| 72 | +--------------------------------------------------------------------------- |
| 73 | +Forms |
| 74 | + -Reuse of change logic across multiple inputs |
| 75 | + -Handling Form Submission |
| 76 | + -Controlling other form element:select,text,textarea,number |
| 77 | + -Form Validation |
| 78 | + -Controlled Component |
| 79 | + -UnControlled Component |
| 80 | + |
| 81 | +What is Controlled Component: |
| 82 | + A component in reactjs is referred to as controlled when we let react control the component for us. |
| 83 | + It means that the component controls the input form, and all of its changes are completely driven by event handlers like |
| 84 | + setState(). |
| 85 | + Also the component controls the render and keep the data form in the component state. |
| 86 | + |
| 87 | +What is Uncontrolled Component: |
| 88 | + Uncontrolled component does not use state. |
| 89 | + So uncontrolled component do not depend upon any state of input element or any event handler. |
| 90 | + This type of component does not care about real-time input changes. |
| 91 | + |
| 92 | +createRef creates a ref object which can contain arbitrary value. |
| 93 | + |
| 94 | +Validator |
| 95 | + -Form Validation |
| 96 | + |
| 97 | +We need to install from project folder |
| 98 | + npm install validator |
| 99 | + |
| 100 | + |
| 101 | +-------------------------------------------------------------------------------- |
| 102 | +Routing |
| 103 | + -Installation |
| 104 | + -Basic |
| 105 | + -Handling Not Found(404) |
| 106 | + -Parameters(Url & Query) |
| 107 | + -Nesting |
| 108 | + |
| 109 | +What is React Router |
| 110 | + Routing is the process in which a user is directed to different pages based on their action or request. |
| 111 | + ReactJs Router is mainly used for developing Single Page Web Application.And used to define multiple routes |
| 112 | + in the application. |
| 113 | + |
| 114 | +Need of React Router |
| 115 | + |
| 116 | +React Router Installation |
| 117 | + npm install react-router-dom --save |
| 118 | + |
| 119 | +------------------------------------------------------------------------------------ |
| 120 | +HTTP |
| 121 | + Fetch API |
| 122 | + Axios library |
| 123 | + Using with React(Http GET) |
| 124 | + Refactoring for Reuse |
| 125 | + Http POST,PUT,DELETE,GET |
| 126 | + |
| 127 | +Axios is library in react to consume API based on promise HTTP client |
| 128 | + GET |
| 129 | + POST |
| 130 | + PUT |
| 131 | + DELETE |
| 132 | + |
| 133 | +Fetch API is a browser based in-built web API |
| 134 | + |
| 135 | +Fetch API is an inbuilt JavaScript method for getting resources from a server or an API endpoint. |
| 136 | + http://localhost:8080/myapp/getData |
| 137 | +To use axios in our project we need to install axios library |
| 138 | + npm install axios |
| 139 | + |
| 140 | +axios.get(url[,config]) |
| 141 | +axios.post(url[,data[,config]]) |
| 142 | +axios.put(url[,data[,config]]) |
| 143 | +axios.delete(url[,config]) |
| 144 | + |
| 145 | + |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | + |
| 152 | + |
0 commit comments