React
JS Library for creating UI.
JSX
JavaScript Extension Syntax
It lets us write HTML directly inside JS.
JSX -----> babel -----> JS
https://vitejs.dev/guide/
- npm create vite@latest
- npm install
- npm run dev
Writing Markup in JSX Rule:-
1. Return a single root element
2. Close all the tags
3. camelCase most of the things
React Fragment
Fragments let you group a list of children without adding extra nodes to the DOM.
onClick
onMouseHover
event.preventDefault() - ye form ko submit hone ke bad default behavior ko stop kar deta hai, ex- page refresh
State in React
The state is a built-in React object that is used to contain data or information about the component.
A component's state can change over time; whenever it changes, the component re-renders.
Hooks
Hooks were a new addition in React 16.8.
They let you use state and other React features without writing a class.
nayi value agar purani value ko use kare to callback use karenge
agar componet change nahi hoga setCount me to React detect kar lega or dobara render nahi karwayega, react apna resource save karega
agar componet change nahi hoga setCount me to React detect kar lega or dobara render nahi karwayega, react apna resource save karega
useState me agar function pass kar rahe ha to hamesa [useState(function-name)] kake ke call kare, nahi to [useState(function-name())] es trah likhne se wo har bar call hota rahega ,hamko to bas ek bar chiye value initillize karne ke liye-
ex- math.random vala example yaad karoo
0 Comments