- React CDN - https://legacy.reactjs.org/docs/cdn-links.html
- Github - https://github.com/namastedev/namaste-react
- Discord - https://discord.com/channels/1057696352890519662/1060238868756037632/threads/1140880978752065637
- How React internal works - https://www.youtube.com/watch?v=7YhdqIR2Yzo
- Bundler - https://www.showwcase.com/show/26900/what-is-a-bundler
- bundle code with parcel for production env - npx parcel build .\Inception\index.html & remove the "main" from package.json file
- Last 2 version of any browsers supported using browserslist : []
Parcel Bundler - https://github.com/parcel-bundler/parcel
- run the server - npx parcel .\Inception\index.html
- HMR - hot module replacement
- File watching algorithm - written in c++
- Light weight algo written in rust
- Caching things so every time no need to start from scratch.
- Image optimization
- Consistent hashing
- code splitting , differential bundling - support older browser and new browser
- tree shaking
- Diagnostic report - npx parcel build .\Inception\index.html --experimental-scope-hoisting --no-minify --no-source-maps --no-cache --log-level 4 --experimental-skip-optimization
- Parcel is a web application bundler, differentiated by its developer experience. It offers blazing fast performance utilizing multicore processing, and requires zero configuration.
- Host on https
- package.json has script tag with the help of that we can run the command : npm run start , npm run build
- npm run start - run the server
- npm run build - build the code for production
- npm run build -- --no-minify - build the code for production without minification
- JSX make our developer life easy , JSX is not a requirement for using React. Using React without JSX is especially convenient when you don't want to set up compilation in your build environment.
- Babel is JS compiler which is converted JSX into react.createEkement() function
- Babel is a JavaScript compiler. Use next generation JavaScript, today.
- Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments. ( support new script in old browser )
- class based component: old way write code fucntional components: new way to write code alwyas it starts with capital letter
- component composition - combine multiple components
- using {} we can write JS code inside JSX
- way to render react component root.render();
- props - props are immutable ( can not be changed )
- props are used to pass data from parent/child to child/parent component (argument to the function)
- config driven UI - we can pass the data from outside of the component
- with map function we can iterate the array and return the JSX
{restObj.map((restaurantData) => (
<RestaurantCard key={restaurantData.data.id} restData={restaurantData} />
))}
- key is used to identify the component uniquely
- Index as a key is an anti-pattern - https://robinpokorny.medium.com/index-as-a-key-is-an-anti-pattern-e0349aece318
- folder/file structure : https://legacy.reactjs.org/docs/faq-structure.html
- export default - export the component as a default
- export - export the component as a named export
- import - import the component
- create super power component using hooks
- Hooks are a new addition in React 16.8. They let you use state and other React features without writing a class.
- useState - useState is a Hook that allows you to have state variables in functional components. You pass the initial state to this function and it returns a variable with the current state value (not necessarily the initial state) and another function to update this value.
const [listOfRestaurants, setListOfRestaurants] = useState(restObj);
whenever state varibale changes react re-render the component.
-
useEffect - The Effect Hook lets you perform side effects in function components: useEffect is a React hook that triggers a side effect when a dependency changes. It is a close replacement for componentDidMount, componentDidUpdate, and componentWillUnmount.
-
virtual DOM - it is not actual DOM , it is a representation of actual DOM.
-
React fiber : https://github.com/acdlite/react-fiber-architecture
-
Monolithic architecture - https://www.youtube.com/watch?v=5NOI3y6Z0rk
-
load the page --> render --> api call ---> rerender the page
-
useEffect called after the render and after the DOM has been updated with the changes.
-
usestate change the header.
const [isLoggedin, setIsLoggedin] = useState(true);
onClick={() => setIsLoggedin(false)}