1. What is React?
- JavaScript library to build dynamic and interactive user interfaces.
- Developed at Facebook in 2011.
- Currently most widely used JS library for front-end development.
- Used to create Single Page Application (SPA).
2. Working of DOM?
- Browser takes HTML and create DOM.
- JS helps us modify DOM based on user actions or events.
- In big applications, Working with DOM becomes complicated.
3. Problems with JS?
- In design - Mental model is important.
- React has a simpler mental model.
- JS is cumbersome.
- JS is Error-prone.
- JS is hard to maintain.
4. Working of React?
- No need to worry about querying and updating DOM.
- React creates a web page with small and reusable components.
- React will take care of creating and updating DOM elements.
- IT saves a lot of time.
5. JS vs React?
- JS is imperative: You define steps to reach your desire state.
- React is Declarative: You define the target UI state and then React figures out how to reach that state.
6. Intro to components?
React application is a tree of components with App component as the root bringing everything together.
- What is IDE?
- IDE stands for Integrated Development Environment.
- Software suite that consolidates basic tools required for software development.
- Central hub for coding, finding problems, and testing.
- Designed to improve developer efficiency.
- Need of IDE?
- Streamlines development.
- Increase productivity.
- Simplifies complex tasks.
- Offers a unified workspace.
- IDE Features:
- Code Autocomplete
- Syntax highlighting.
- Simplifies complex tasks.
- Version control.
- Error checking.
- VS code extensions
- Live server / Live preview
- Prettier (Format on save)
- Line wrap
- tab size from 4 to 2
7. Create a First React App
- Official tools is CRA (Create React App).
- Vite is a modern tool to create React project.
- Vite produces quick and small bundle size.
- Vite: use "npm run dev" to launch dev server.
- Use "npm start" for CRA.
- Commonds:
- Vite website: npm create vite@latest
- npm i / install
- Start server: npm run dev
- devDependencies: Use locally in the entire code.
10. File extensions
JS:
- Stands for JS
- Contains regular JS code.
- Used for general logic and components.
JSX:
- Stands for JS XML.
- Combines JS with HTML like tags.
- Makes it easier to design UI components.
11. Class vs Functions components
Class components:
- Stateful: Can manage state.
- Lifecycle: Access to lifecycle methods.
- Verbose: More boilerplate code.
- Not preferred anymore.
Functional components:
- Initially stateless
- Can use hooks for state and effects.
- Simpler and more concise.
- More popular.
12. What is JSX?
- Definition: JSX determines how the UI will look wherever the components is used.
- Not HTML: Though it resembles HTML, you're actually writing JSX, which stands for JS XML.
- Conversion: JSX gets converted to regular JS.
- "Babeljs.io/repl" is a tool that allows you to see how JSX is transformed into JS.
13. Exporting components
14. Other important points
- Naming: Must be capitalized - Lowercase for default HTML.
- HTML: unlike vanilla JS where you can't directly write HTML, in React, you can embed HTML like syntax using JSX.
- CSS: In React, CSS can be directly imported into component files, allowing for modular and component specific styling.
15. Dynamic components
- Dynamic content: JSX allows the creation of dynamic and interactive UI components.
- JS expressions: Using {}, we can embed any JS expression directly within JSX. This includes variables, function calls, and more.
16. Reusable components
- Install from bootstrap website : "npm i bootstrap@5.3.2"
- Import "import "bootstrap/dist/css/bootstrap.min.css";"
18. What is Fagment?
what? - Allows grouping of multiple elements without extra DOM nodes.
why? - Return multiple element without a wrapping parent.
Cleaner DOM and consistent styling.
how? - Two syntaxes
19. Map Method:
- Purpose: Render lists from array data.
- JSX elements: Transfer array items into JSX.
- Inline rendering: Directly inside JSX.
4. Key prop: Assign unique key for optimized re-renders.
- Displaying content based on certain conditions.
- Allows for dynamic user interface.
Methods:
- If-else statements: Choose between two blocks of content.
- Ternary operators: Quick way to choose between two options.
- Logical operators: Useful for rendering content when a condition is true.
Benefits:
- Enhances user experience.
- Reduces unnecessary rendering Makes apps more interactive and responsive.
21. Passing data via Props:
Props in React:
- Short for properties.
- Mechanism for passing data.
- Read-only by default.
Usage:
- Pass data from parent to child component.
- Makes components reusable.
- Defined as attributes in JSX.
Key points:
- Data flows one-way (downwards).
- Props are immutable.
- Used for communication between components.
Eg: <Header title="My App" />
Others curious image:
Videos:
0 Comments