Getting Started with React, When You’re an Angular DeveloperFabrit Global
If you’re an Angular developer looking into expanding your stack with React, this presentation will come in handy! It is an insightful introduction to React in comparison with Angular, where you will find all the basic knowledge you need to get started.
We’ll deep-dive into tech details such as:
● Virtual DOM
● JSX
● Functional vs Class-Based Components
● State
● How to Style
● Requests
● Upgrading: Redux and Flux and more!
You can also check out the full article version here: https://blog.fabritglobal.com/product-development/getting-started-with-react-angular-developer/
React is a JavaScript library for building user interfaces that aims to solve issues with data changing over time in large web applications. It introduces components, re-rendering on data changes rather than mutating data, and a virtual DOM for efficient re-rendering. React uses a unidirectional data flow and one-way data binding that improves design architecture and code reusability. Related technologies like JSX, Flux, GraphQL, Relay, and React Native further enhance React's capabilities.
This document outlines an agenda for a workshop on React and Flux. The workshop will begin with light introductions to React and Flux concepts, followed by demos of building applications with each. More details on React and Flux will be provided. Code repositories for the demos will be shared. The workshop aims to convey high-level concepts like components, one-way data flow, and separation of concerns between views and data. Recipes for conditional content and collections will be demonstrated.
1) Single page applications (SPAs) use JavaScript to dynamically update the content of a single web page rather than loading entire new pages. This reduces page refreshes.
2) React is a popular JavaScript library for building user interfaces, especially for SPAs. It uses a virtual DOM for faster rendering.
3) Create-React-App is a command line interface that sets up a React project with common dependencies like Babel and Webpack preconfigured.
This document provides an introduction to React including:
- React is a UI library that uses a component-based architecture and focuses on rendering views. It is not an MVC framework.
- React uses a virtual DOM for efficient updates rather than directly manipulating the real DOM. This improves performance.
- React components are self-contained pieces of code that receive data and return rendered output. An application is made of composable components.
- JavaScript knowledge is fundamental for React as components are written in JSX which compiles to JavaScript.
This document discusses React.js and its use for frontend development. It covers the key features and advantages of React, how it works, its architecture including components and the virtual DOM, comparisons to other frameworks like Angular, and examples of companies that use React like Facebook and Netflix. The summary is:
React.js is a popular library for building user interfaces that uses reusable components and a virtual DOM for improved performance. It has advantages over frameworks like Angular in being easier to learn and use due to its simpler architecture and unidirectional data flow. Major companies like Facebook use React for significant parts of their applications, demonstrating its widespread adoption.
This document provides an introduction to ReactJS, including:
- ReactJS was developed by Facebook in 2013 and is currently at version 15.3.2; it is a view library rather than a framework
- Reasons for choosing ReactJS include faster websites, reusable views, a large community, ease of writing tests, and integration with other frameworks
- The document discusses Webpack, JSX, ES6 features, and Redux, which are important technologies to learn when using ReactJS
This document provides an overview of React components. It discusses functional components, which are stateless and return HTML, and class components, which are stateful and require a render method. Components can contain other components and receive props. The state object stored in class components allows re-rendering when its values change. Events in React use camelCase syntax and are handled with functions defined in the component. The event object provides information about the event.
Web Development with Delphi and React - ITDevCon 2016Marco Breveglieri
This document provides an overview of modern web development with Delphi and React. It discusses how traditional "fat" web applications are no longer preferred and introduces key concepts in modern web development like JavaScript, HTML5 APIs, DOM, jQuery, single page applications, and React. It explains what React is and core React concepts like components, properties, state, virtual DOM, JSX syntax and lifecycle methods. It also discusses how Delphi can be used to build backend APIs that a React front-end can communicate with.
React is a JavaScript library for building user interfaces and applications. It uses components rather than templates, implements a one-way data flow downwards and re-renders components on data changes rather than mutating them directly. The virtual DOM in React allows for simple and fast re-rendering. Key aspects of React include components, one-way data flow, re-rendering without mutation, the virtual DOM, JSX syntax and React Native for building mobile apps. Flux is an architecture pattern used for state management in React, implementing unidirectional data flow through actions, a dispatcher, stores and views.
React.js is a JavaScript library developed by awesome engineers at Facebook. React is really fast, any app developed in React can handle complex updates and still feel quick and responsive. It uses reusable components, it’s modularity makes it really easy to maintain JavaScript (spaghetti code). React performs best with large programs that constantly require data changes, and this is a very famous language, understanding. React will definitely make you more employable.
Prerequisite to understanding React.js is JavaScript fundamentals,
The document discusses progressive web apps and React. It begins by introducing progressive web apps and their benefits over traditional web apps and native apps. It then covers prerequisites for building progressive web apps with React including HTML, JavaScript, Node.js and CLI knowledge. The document proceeds to discuss key React topics like components, virtual DOM, JSX, props and state. It also covers service workers, manifest files and tools for testing progressive web apps.
This document provides an overview and introduction to React JS. It discusses that React JS is a JavaScript library developed by Facebook for building user interfaces and reusable UI components. It encourages creation of reusable components that present data that changes over time. The document also covers React JS features, architecture, components, best practices, pros and cons, and provides useful links for examples and environment setup.
- Angular is a framework that provides many features out of the box like components, templates, state management, properties, events, HTTP, and routing.
- React is a library focused on components but other aspects like state, properties, events, HTTP, and routing require additional libraries.
- The presentation compared Angular and React on their approaches to components, templates, state, properties, events, HTTP, and routing.
This document provides an overview and introduction to React, Redux, and related technologies. It discusses why React is useful, comparisons to other frameworks, an overview of Flux and how Redux differs, concepts like actions, reducers, and stores in Redux, using Immutable.js with Redux, and examples of React and Redux applications. It also touches on ES6 features, useful related modules, resources for learning more, and potential future directions.
This document provides an introduction to React, a JavaScript library for building user interfaces. It discusses React's fundamentals like components and unidirectional data flow. It also covers topics like JSX, props, state, lifecycles, and demos creating a component. The document aims to explain what React is, its core concepts, and how to get started using it to build user interfaces.
React Js Basic Details and Descriptions
Frontend Javascript Library, to make decent SPA
The fastest way to build a segregated component based front end for software development.
ReactJs is a JavaScript library for building user interfaces that uses components and a virtual DOM for efficient updates. It is intended to make development of UI components easy and modular. React implements unidirectional data flow and uses components, a virtual DOM, JSX syntax, and isomorphic rendering to provide a declarative and efficient way to build user interfaces.
Google Developer Group LNCTS: Empowering Innovation and Collaboration
Google Developer Group LNCTS is a dynamic and thriving community uniting tech enthusiasts, developers, and innovators from LNCT Group of Colleges, Bhopal. Our mission is to foster a collaborative environment where learning, creativity, and innovation come to life.
We strive to bridge the gap between students and cutting-edge technology through a diverse range of engaging activities. From hands-on workshops and hackathons to thought-provoking speaker sessions, our events are designed to provide practical skills, inspire creative problem-solving, and encourage collaboration that leads to impactful projects.
At GDG LNCTS, we believe in the power of community-driven growth. By connecting like-minded individuals, we cultivate a culture of shared knowledge and mutual support, empowering students to excel in their technical journeys. Whether you’re looking to sharpen your coding skills, connect with industry experts, or explore the latest advancements in technology, GDG LNCTS offers a platform to learn, grow, and innovate.
🌐 Stay Connected with GDG LNCTS:
Instagram: Follow us
LinkedIn: Connect with us
WhatsApp Community: Join here
X: Like our page
Join us in shaping the future of technology and making a meaningful impact in the world. Together, let’s innovate, collaborate, and thrive!
React is a declarative, efficient, and flexible JavaScript library for building user interfaces. It uses virtual DOM which improves performance and can render on both client and server. React encourages a component-based approach where UI is broken into independent reusable pieces that accept external data through properties. Components manage their own state which allows the UI to update over time in response to user input. This makes React code more predictable and easier to debug than traditional two-way data binding.
React is a powerful JavaScript library for building dynamic user interfaces. It emphasizes a component-based architecture, allowing developers to create reusable UI elements. With a virtual DOM for efficient rendering, React ensures fast updates and smooth user experiences. JSX syntax blends HTML with JavaScript, simplifying the creation of interactive UIs.
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil DisobedienceRajdeep Bavaliya
Dive into the powerful journey from Thoreau’s 19th‑century essay to Gandhi’s mass movement, and discover how one man’s moral stand became the backbone of nonviolent resistance worldwide. Learn how conscience met strategy to spark revolutions, and why their legacy still inspires today’s social justice warriors. Uncover the evolution of civil disobedience. Don’t forget to like, share, and follow for more deep dives into the ideas that changed the world.
M.A. Sem - 2 | Presentation
Presentation Season - 2
Paper - 108: The American Literature
Submitted Date: April 2, 2025
Paper Name: The American Literature
Topic: Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
[Please copy the link and paste it into any web browser to access the content.]
Video Link: https://youtu.be/HXeq6utg7iQ
For a more in-depth discussion of this presentation, please visit the full blog post at the following link: https://rajdeepbavaliya2.blogspot.com/2025/04/thoreau-s-influence-on-gandhi-the-evolution-of-civil-disobedience.html
Please visit this blog to explore additional presentations from this season:
Hashtags:
#CivilDisobedience #ThoreauToGandhi #NonviolentResistance #Satyagraha #Transcendentalism #SocialJustice #HistoryUncovered #GandhiLegacy #ThoreauInfluence #PeacefulProtest
Keyword Tags:
civil disobedience, Thoreau, Gandhi, Satyagraha, nonviolent protest, transcendentalism, moral resistance, Gandhi Thoreau connection, social change, political philosophy
This document provides an introduction to ReactJS, including:
- ReactJS was developed by Facebook in 2013 and is currently at version 15.3.2; it is a view library rather than a framework
- Reasons for choosing ReactJS include faster websites, reusable views, a large community, ease of writing tests, and integration with other frameworks
- The document discusses Webpack, JSX, ES6 features, and Redux, which are important technologies to learn when using ReactJS
This document provides an overview of React components. It discusses functional components, which are stateless and return HTML, and class components, which are stateful and require a render method. Components can contain other components and receive props. The state object stored in class components allows re-rendering when its values change. Events in React use camelCase syntax and are handled with functions defined in the component. The event object provides information about the event.
Web Development with Delphi and React - ITDevCon 2016Marco Breveglieri
This document provides an overview of modern web development with Delphi and React. It discusses how traditional "fat" web applications are no longer preferred and introduces key concepts in modern web development like JavaScript, HTML5 APIs, DOM, jQuery, single page applications, and React. It explains what React is and core React concepts like components, properties, state, virtual DOM, JSX syntax and lifecycle methods. It also discusses how Delphi can be used to build backend APIs that a React front-end can communicate with.
React is a JavaScript library for building user interfaces and applications. It uses components rather than templates, implements a one-way data flow downwards and re-renders components on data changes rather than mutating them directly. The virtual DOM in React allows for simple and fast re-rendering. Key aspects of React include components, one-way data flow, re-rendering without mutation, the virtual DOM, JSX syntax and React Native for building mobile apps. Flux is an architecture pattern used for state management in React, implementing unidirectional data flow through actions, a dispatcher, stores and views.
React.js is a JavaScript library developed by awesome engineers at Facebook. React is really fast, any app developed in React can handle complex updates and still feel quick and responsive. It uses reusable components, it’s modularity makes it really easy to maintain JavaScript (spaghetti code). React performs best with large programs that constantly require data changes, and this is a very famous language, understanding. React will definitely make you more employable.
Prerequisite to understanding React.js is JavaScript fundamentals,
The document discusses progressive web apps and React. It begins by introducing progressive web apps and their benefits over traditional web apps and native apps. It then covers prerequisites for building progressive web apps with React including HTML, JavaScript, Node.js and CLI knowledge. The document proceeds to discuss key React topics like components, virtual DOM, JSX, props and state. It also covers service workers, manifest files and tools for testing progressive web apps.
This document provides an overview and introduction to React JS. It discusses that React JS is a JavaScript library developed by Facebook for building user interfaces and reusable UI components. It encourages creation of reusable components that present data that changes over time. The document also covers React JS features, architecture, components, best practices, pros and cons, and provides useful links for examples and environment setup.
- Angular is a framework that provides many features out of the box like components, templates, state management, properties, events, HTTP, and routing.
- React is a library focused on components but other aspects like state, properties, events, HTTP, and routing require additional libraries.
- The presentation compared Angular and React on their approaches to components, templates, state, properties, events, HTTP, and routing.
This document provides an overview and introduction to React, Redux, and related technologies. It discusses why React is useful, comparisons to other frameworks, an overview of Flux and how Redux differs, concepts like actions, reducers, and stores in Redux, using Immutable.js with Redux, and examples of React and Redux applications. It also touches on ES6 features, useful related modules, resources for learning more, and potential future directions.
This document provides an introduction to React, a JavaScript library for building user interfaces. It discusses React's fundamentals like components and unidirectional data flow. It also covers topics like JSX, props, state, lifecycles, and demos creating a component. The document aims to explain what React is, its core concepts, and how to get started using it to build user interfaces.
React Js Basic Details and Descriptions
Frontend Javascript Library, to make decent SPA
The fastest way to build a segregated component based front end for software development.
ReactJs is a JavaScript library for building user interfaces that uses components and a virtual DOM for efficient updates. It is intended to make development of UI components easy and modular. React implements unidirectional data flow and uses components, a virtual DOM, JSX syntax, and isomorphic rendering to provide a declarative and efficient way to build user interfaces.
Google Developer Group LNCTS: Empowering Innovation and Collaboration
Google Developer Group LNCTS is a dynamic and thriving community uniting tech enthusiasts, developers, and innovators from LNCT Group of Colleges, Bhopal. Our mission is to foster a collaborative environment where learning, creativity, and innovation come to life.
We strive to bridge the gap between students and cutting-edge technology through a diverse range of engaging activities. From hands-on workshops and hackathons to thought-provoking speaker sessions, our events are designed to provide practical skills, inspire creative problem-solving, and encourage collaboration that leads to impactful projects.
At GDG LNCTS, we believe in the power of community-driven growth. By connecting like-minded individuals, we cultivate a culture of shared knowledge and mutual support, empowering students to excel in their technical journeys. Whether you’re looking to sharpen your coding skills, connect with industry experts, or explore the latest advancements in technology, GDG LNCTS offers a platform to learn, grow, and innovate.
🌐 Stay Connected with GDG LNCTS:
Instagram: Follow us
LinkedIn: Connect with us
WhatsApp Community: Join here
X: Like our page
Join us in shaping the future of technology and making a meaningful impact in the world. Together, let’s innovate, collaborate, and thrive!
React is a declarative, efficient, and flexible JavaScript library for building user interfaces. It uses virtual DOM which improves performance and can render on both client and server. React encourages a component-based approach where UI is broken into independent reusable pieces that accept external data through properties. Components manage their own state which allows the UI to update over time in response to user input. This makes React code more predictable and easier to debug than traditional two-way data binding.
React is a powerful JavaScript library for building dynamic user interfaces. It emphasizes a component-based architecture, allowing developers to create reusable UI elements. With a virtual DOM for efficient rendering, React ensures fast updates and smooth user experiences. JSX syntax blends HTML with JavaScript, simplifying the creation of interactive UIs.
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil DisobedienceRajdeep Bavaliya
Dive into the powerful journey from Thoreau’s 19th‑century essay to Gandhi’s mass movement, and discover how one man’s moral stand became the backbone of nonviolent resistance worldwide. Learn how conscience met strategy to spark revolutions, and why their legacy still inspires today’s social justice warriors. Uncover the evolution of civil disobedience. Don’t forget to like, share, and follow for more deep dives into the ideas that changed the world.
M.A. Sem - 2 | Presentation
Presentation Season - 2
Paper - 108: The American Literature
Submitted Date: April 2, 2025
Paper Name: The American Literature
Topic: Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
[Please copy the link and paste it into any web browser to access the content.]
Video Link: https://youtu.be/HXeq6utg7iQ
For a more in-depth discussion of this presentation, please visit the full blog post at the following link: https://rajdeepbavaliya2.blogspot.com/2025/04/thoreau-s-influence-on-gandhi-the-evolution-of-civil-disobedience.html
Please visit this blog to explore additional presentations from this season:
Hashtags:
#CivilDisobedience #ThoreauToGandhi #NonviolentResistance #Satyagraha #Transcendentalism #SocialJustice #HistoryUncovered #GandhiLegacy #ThoreauInfluence #PeacefulProtest
Keyword Tags:
civil disobedience, Thoreau, Gandhi, Satyagraha, nonviolent protest, transcendentalism, moral resistance, Gandhi Thoreau connection, social change, political philosophy
Ray Dalio How Countries go Broke the Big CycleDadang Solihin
A complete and practical understanding of the Big Debt Cycle. A much more practical understanding of how supply and demand really work compared to the conventional economic thinking. A complete and practical understanding of the Overall Big Cycle, which is driven by the Big Debt Cycle and the other major cycles, including the big political cycle within countries that changes political orders and the big geopolitical cycle that changes world orders.
Paper 109 | Archetypal Journeys in ‘Interstellar’: Exploring Universal Themes...Rajdeep Bavaliya
Get ready to embark on a cosmic quest as we unpack the archetypal power behind Christopher Nolan’s ‘Interstellar.’ Discover how hero’s journey tropes, mythic symbols like wormholes and tesseracts, and themes of love, sacrifice, and environmental urgency shape this epic odyssey. Whether you’re a film theory buff or a casual viewer, you’ll learn why Cooper’s journey resonates with timeless myths—and what it means for our own future. Smash that like button, and follow for more deep dives into cinema’s greatest stories!
M.A. Sem - 2 | Presentation
Presentation Season - 2
Paper - 109: Literary Theory & Criticism and Indian Aesthetics
Submitted Date: April 5, 2025
Paper Name: Literary Theory & Criticism and Indian Aesthetics
Topic: Archetypal Journeys in ‘Interstellar’: Exploring Universal Themes in Nolan’s Cosmic Odyssey
[Please copy the link and paste it into any web browser to access the content.]
Video Link: https://youtu.be/vHLaLZPHumk
For a more in-depth discussion of this presentation, please visit the full blog post at the following link: https://rajdeepbavaliya2.blogspot.com/2025/04/archetypal-journeys-in-interstellar-exploring-universal-themes-in-nolan-s-cosmic-odyssey.html
Please visit this blog to explore additional presentations from this season:
Hashtags:
#ChristopherNolan #Interstellar #NolanFilms #HeroJourney #CosmicOdyssey #FilmTheory #ArchetypalCriticism #SciFiCinema #TimeDilation #EnvironmentalCinema #MythicStorytelling
Keyword Tags:
Interstellar analysis, Christopher Nolan archetypes, hero’s journey explained, wormhole symbolism, tesseract meaning, myth in sci-fi, cinematic archetypes, environmental themes film, love across time, Nolan film breakdown
THE QUIZ CLUB OF PSGCAS BRINGS T0 YOU A FUN-FILLED, SEAT EDGE BUSINESS QUIZ
DIVE INTO THE PRELIMS OF BIZCOM 2024
QM: GOWTHAM S
BCom (2022-25)
THE QUIZ CLUB OF PSGCAS
This presentation has been made keeping in mind the students of undergraduate and postgraduate level. In this slide try to present the brief history of Chaulukyas of Gujrat up to Kumarpala To keep the facts in a natural form and to display the material in more detail, the help of various books, websites and online medium has been taken. Whatever medium the material or facts have been taken from, an attempt has been made by the presenter to give their reference at the end.
Chaulukya or Solanki was one of the Rajputs born from Agnikul. In the Vadnagar inscription, the origin of this dynasty is told from Brahma's Chauluk or Kamandalu. They ruled in Gujarat from the latter half of the tenth century to the beginning of the thirteenth century. Their capital was in Anahilwad. It is not certain whether it had any relation with the Chalukya dynasty of the south or not. It is worth mentioning that the name of the dynasty of the south was 'Chaluky' while the dynasty of Gujarat has been called 'Chaulukya'. The rulers of this dynasty were the supporters and patrons of Jainism.
This presentation has been made keeping in mind the students of undergraduate and postgraduate level. To keep the facts in a natural form and to display the material in more detail, the help of various books, websites and online medium has been taken. Whatever medium the material or facts have been taken from, an attempt has been made by the presenter to give their reference at the end.
In the seventh century, the rule of Sindh state was in the hands of Rai dynasty. We know the names of five kings of this dynasty- Rai Divji, Rai Singhras, Rai Sahasi, Rai Sihras II and Rai Sahasi II. During the time of Rai Sihras II, Nimruz of Persia attacked Sindh and killed him. After the return of the Persians, Rai Sahasi II became the king. After killing him, one of his Brahmin ministers named Chach took over the throne. He married the widow of Rai Sahasi and became the ruler of entire Sindh by suppressing the rebellions of the governors.
"Geography Study Material for Class 10th" provides a comprehensive and easy-to-understand resource for key topics like Resources & Development, Water Resources, Agriculture, Minerals & Energy, Manufacturing Industries, and Lifelines of the National Economy. Designed as per the latest NCERT/JKBOSE syllabus, it includes notes, maps, diagrams, and MODEL question Paper to help students excel in exams. Whether revising for exams or strengthening conceptual clarity, this material ensures effective learning and high scores. Perfect for last-minute revisions and structured study sessions.
How to Manage Multi Language for Invoice in Odoo 18Celine George
Odoo supports multi-language functionality for invoices, allowing you to generate invoices in your customers’ preferred languages. Multi-language support for invoices is crucial for businesses operating in global markets or dealing with customers from different linguistic backgrounds.
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecdrazelitouali
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
ABCs of Bookkeeping for Nonprofits TechSoup.pdfTechSoup
Accounting can be hard enough if you haven’t studied it in school. Nonprofit accounting is actually very different and more challenging still.
Need help? Join Nonprofit CPA and QuickBooks expert Gregg Bossen in this first-time webinar and learn the ABCs of keeping books for a nonprofit organization.
Key takeaways
* What accounting is and how it works
* How to read a financial statement
* What financial statements should be given to the board each month
* What three things nonprofits are required to track
What features to use in QuickBooks to track programs and grants
Exploring Ocean Floor Features for Middle SchoolMarie
This 16 slide science reader is all about ocean floor features. It was made to use with middle school students.
You can download the PDF at thehomeschooldaily.com
Thanks! Marie
2. Brief history of Web Applications
● Initially: static HTML files only with HTML forms for input
● Common Gateway Interface (CGI)
○ Certain URLs map to executable programs that generate web page
○ Program exits after Web page complete
○ Introduced the notion of stateless servers: each request independent, no state
carried over from previous requests. (Made scale-out architectures easier)
○ Perl typically used for writing CGI programs
3. First-generation web app frameworks
Examples: (PHP
, ASP
.net, Java servlets)
● Incorporate language runtime system directly into Web server
● Templates: mix code and HTML - HTML/CSS describes view
● Web-specific library packages:
○ URL handling
○ HTML generation
○ Sessions
○ Interfacing to databases
4. Second-generation frameworks
Examples: (Ruby on Rails, Django):
● Model-view-controller: stylized decomposition of applications
● Object-relational mapping (ORM): simplify the use of databases (make
database tables and rows appear as classes and objects)
○ Easier fetching of dynamic data
5. Third-generation frameworks
Example: AngularJS
● JavaScript frameworks running in browser - More app-like web apps
○ Interactive, quick responding applications - Don't need server round-trip
● Frameworks not dependent on particular server-side capabilities
○ Node.js - Server side JavaScript
○ No-SQL database (e.g. MongoDB)
● Many of the concepts of previous generations carry forward
○ Model-view-controller
○ Templates - HTML/CSS view description
6. Model-View-Controller (MVC) Pattern
● Model: manages the application's data
○ JavaScript objects. PhotoApp: User names, pictures, comments, etc.
● View: what the web page looks like
○ HTML/CSS. PhotoApp: View Users, View photo with comments
● Controller: fetch models and control view, handle user interactions
○ JavaScript code. PhotoApp: DOM event handlers, web server communication
MVC pattern been around since the late 1970's
○ Originally conceived in the Smalltalk project at Xerox PARC
7. View Generation
● Web App: Ultimately need to generate HTML and CSS
● Templates are commonly used technique. Basic ideas:
○ Write HTML document containing parts of the page that are always the same.
○ Add bits of code that generate the parts that are computed for each page.
○ The template is expanded by executing code snippets, substituting the results into the
document.
● Benefits of templates (Compare with direct JavaScript to DOM programming)
○ Easy to visualize HTML structure
○ Easy to see how dynamic data fits in
○ Can do either on server or browser
8. Controllers
● Third-generation: JavaScript running in browser
Responsibilities:
● Connect models and views
○ Server communication: Fetch models, push updates
● Control view templates
○ Manage the view templates being shown
● Handle user interactions
○ Buttons, menus, and other interactive widgets
9. Model Data
● All non-static information needed by the view templates or controllers
● Traditionally tied to application's database schema
○ Object Relational Mapping (ORM) - A model is a table row
● Web application's model data needs are specified by the view designers
But need to be persisted by the database
● Conflict: Database Schemas don't like changing frequently but web
application model data might (e.g. user will like this view better if we add …
and lose ...)
10. Fourth-generation frameworks
Examples: React.js, Vue.js, Angular(v2)
● Many of the concepts of previous generations carry forward
○ JavaScript in browser
○ Model-view-controllers
○ Templates
● Focus on JavaScript components rather than pages/HTML
○ Views apps as assembled reusable components rather than pages.
○ Software engineering focus: modular design, reusable components, testability, etc.
● Virtual DOM
○ Render view into DOM-like data structure (not real DOM)
○ Benefits: Performance, Server-side rendering, Native apps
11. ReactJS
● JavaScript framework for writing the web applications
○ LikeAngularJS - Snappy response from running in browser
○ Less opinionated: only specifies rendering view and handling user interactions
● Uses Model-View-Controller pattern
○ View constructed from Components using pattern
○ Optional, but commonly used HTML templating
● Minimal server-side support dictated
● Focus on supporting for programming in the large and single page applications
○ Modules, reusable components, testing, etc.
12. ReactJS Web Application Page
<!doctype html>
<html>
<head>
<title>Example</title>
</head>
<body>
<div id="root"></div>
<script src="./webpackOutput/reactApp.bundle.js"></script>
</body>
</html>
ReactJS applications come as a
JavaScript blob that will use the DOM
interface to write the view into the div.
13. ReactJS tool chain
Babel - Transpile language features (e.g. ECMAScript, JSX) to basic JavaScript
Webpack - Bundle modules and resources (CSS, images)
Output loadable with single script tag in any browser
Component #1
Component #2
Component #N
...
Babel
Babel
Babel
Webpack
Output
Bundle.js
React.js
React Components
14. index.js - Render element into browser DOM
import React from 'react';
import ReactDOM from 'react-dom';
import ReactAppView from './components/ReactAppView';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<ReactAppView />
</React.StrictMode>
);
Renders the tree of React elements (single component
named ReactAppView) into the browser's DOM at the
div with id=reactapp.
ES6 Modules - Bring in
React and web app React
components.
15. components/ReactAppView.js - ES6 class definition
import React from 'react';
class ReactAppView extends React.Component {
constructor(props) {
super(props);
...
}
render() { ...
};
export default ReactAppView;
Require method render() - returns React
element tree of the Component's view.
Inherits from React.Component. props is
set to the attributes passed to the
component.
16. ReactAppView render() method
render() {
let label = React.createElement('label', null,'Name: ');
let input = React.createElement('input',{type:'text'});
let h1 = React.createElement('h1',null ,'Hello!');
return React.createElement('div', null, label, input, h1);
}
Returns element tree with div (label, input, and h1) elements
<div>
<label>Name: </label>
<input type="text" … />
<h1>Hello!</h1>
</div>
18. Use JSX to generate calls to createElement
render() {
return (
<div>
<label>Name: </label>
<input type="text" />
<h1>Hello!</h1>
</div>
);
}
● JSX makes building tree look like templated HTML embedded in JavaScript.
19. App.js - use functions to create elements
function App() {
return (
<div>
<label>Name: </label>
<input type="text" />
<h1>Hello!</h1>
</div>
);
}
● More simple and readable
● Improved performance
● Can be used with hooks and state management
21. Programming with JSX
● Need to remember: JSX maps to calls to React.createElement
○ Writing in JavaScript HTML-like syntax that is converted to JavaScript function calls
● React.createElement(type, props, ...children);
○ type: HTML tag (e.g. h1, p) or React.Component
○ props: attributes (e.g. type="text") Uses camelCase!
○ children: Zero or more children which can be either:
■ String or numbers
■ A React element
■ An Array of the above
22. Programming with JSX
● Plain HTML
const myElement = React.createElement('h1', { style:{color:"green"} }, 'I do not use JSX!’);
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(myElement);
● JSX
const myElement = <h1>I Love JSX!</h1>;
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(myElement);
23. JSX Rules
● A React component name must be capitalized (otherwise treated as built-
in components)
● Return multiple HTML elements
const App = () => {
return (
<div>
<h1>Hello World!</h1>
<p>Tanishka here!</p>
</div>
);
}
24. JSX Rules
● Every tag, including self closing tags, must be closed. In case of self
closing tags you have to add a slash at the end
const App = () => {
return (
<>
<img src="./assets/react.svg" alt="" />
</>
);
}
25. JSX Rules
● JSX is closer to JavaScript than to HTML, the React DOM uses the
camelCase naming convention for HTML attribute names.
For example: tabIndex, onChange, and so on.
● "class" and "for" are reserved keywords in JavaScript, so use
"className" and "forHTML" instead, respectively.
26. Styling with React/JSX - lots of different ways
import React from 'react';
import ‘./App.css';
function App() {
return (
<span className="code-name">
...
</span>
);
Webpack can import CSS style sheets:
. code-name {
font-family: Courier New, monospace;
}
Must use className= for HTML
class= attribute (JS keyword
conflict)
27. Use JS in JSX
● Put plain JavaScript code in curly brackets
const App = () => {
const name = "Tanishka";
return (
<>
<h1>My name is {name}</h1>
</>
);
}
28. JSX templates must return a valid children param
● Templates can have JavaScript scope variables and expressions
○ <div>{foo}</div>
■ Valid if foo is in scope (i.e. if foo would have been a valid function call parameter)
○ <div>{foo + 'S' + computeEndingString()}</div>
■ Valid if foo & computeEndString in scope
● Template must evaluate to a value
○ <div>{if (useSpanish) { … } }</div> - Doesn't work: if isn't an expression
○ Same problem with "for loops" and other JavaScript statements that don't return values
● Leads to contorted looking JSX: Example: Anonymous immediate functions
○ <div>{ (function() { if …; for ..; return val;})() }</div>
29. Conditional render in JSX
● Use JavaScript Ternary operator (?:)
<div>{this.state.useSpanish ? <b>Hola</b> : "Hello"}</div>
● Use JavaScript variables
let greeting;
const en = "Hello"; const sp = <b>Hola</b>;
let {useSpanish} = this.prop;
if (useSpanish) {greeting = sp} else {greeting = en};
<div>{greeting}</div>
30. Iteration in JSX
● Use JavaScript array variables
let listItems = [];
for (let i = 0; i < data.length; i++) {
listItems.push(<li key={data[i]}>Data Value {data[i]}</li>);
}
return <ul>{listItems}</ul>;
● Functional programming
<ul>{data.map((d) => <li key={d}>Data Value {d}</li>)}</ul>
key= attribute improves efficiency of rendering on data change
32. React Components
● Independent and reusable blocks of code which work in isolation
● The main advantage of components is that they help reduce redundancy.
33. Types of React Components
● Class components
class Greet extends React.Component {
constructor (props) { … }
render () { return <h1>Hello World!</h1>;}
}
● Functional components:
function Greet() {
return <h1>Hello World!</h1>;
}
Or
const Greet = () => <h1>Hello World!</h1>
34. Nested Components
● Creating more complex User Interfaces and getting rid of redundant code
const Book = () => {
return (
<div>
<h1>Book name : Cracking The Coding Interview</h1>
<h2>Author : Gayle Laakmann McDowell</h2>
</div>
);
};
const BookList = () => {
return (
<div>
<Book />
<Book />
</div>
);
};
38. Component state and input handling
function App() {
let yourName = "";
const handleChange = (event) => {
yourName = event.target.value;
console.log(yourName);
}
return (
<div>
<label>Name: </label>
<input type="text" onChange = {handleChange} />
<h1>Hello {yourName}!</h1>
</div>
);
}
Doesn’t work !
39. State in React
● The state is an object that holds information about a certain
component.
● State allows us to manage changing data in an application.
o It's defined as an object where we define key-value pairs specifying various data we
want to track in the application.
● State change is one of the two things that make a React component
re-render (the other is a change in props)
o In this way, the state stores information about the component and also controls its
behavior.
40. Component state and input handling
import React from 'react';
class ReactAppView extends React.Component {
constructor(props) {
super(props);
this.state = {yourName: ""};
}
handleChange(event) {
this.setState({yourName: event.target.value});
}
....
● Input calls to setState which causes React to call render() again
Make <h1>Hello {this.state.yourName}!</h1>
work
41. One way binding: Type 'D' Character in input box
● JSX statement:
<input type="text" value={this.state.yourName}
onChange={(event) => this.handleChange(event)} />
<h1>Hello {this.state.yourName} !</h1>
Triggers handleChange call with event.target.value == "D"
● handleChange - this.setState({yourName: event.target.value});
this.state.yourName is changed to "D"
● React sees state change and calls render again:
● Feature of React - highly efficient re-rendering
42. Calling React Components from events: A problem
class ReactAppView extends React.Component {
...
handleChange(event) {
this.setState({ yourName: event.target.value });
}
...
}
Understand why:
<input type="text" value={this.state.yourName} onChange={this.handleChange} />
Doesn't work!
43. Calling React Components from events workaround
● Create instance function bound to instance
class ReactAppView extends React.Component {
constructor(props) {
super(props);
this.state = {yourName: ""};
this.handleChange = this.handleChange.bind(this);
}
handleChange(event) {
this.setState({ yourName: event.target.value });
}
44. Calling React Components from events workaround
● Using public fields of classes with arrow functions
class ReactAppView extends React.Component {
constructor(props) {
super(props);
this.state = {yourName: ""};
}
handleChange = (event) => {
this.setState({ yourName: event.target.value });
}
...
45. Calling React Components from events workaround
● Using arrow functions in JSX
class ReactAppView extends React.Component {
…
handleChange(event) {
this.setState({ yourName: event.target.value });
}
render() {
return (
<input type="text" value={this.state.yourName}
onChange={(event) => this.handleChange(event)} />
);
}
46. A digression: camelCase vs dash-case
Word separator in multiword variable name
● Use dashes: active-buffer-entry
● Capitalize first letter of each word: activeBufferEntry
Issue: HTML is case-insensitive but JavaScript is not.
ReactJS's JSX has HTML-like stuff embedded in JavaScript.
ReactJS: Use camelCase for attributes
AngularJS: Used both: dashes in HTML and camelCase in JavaScript!
47. Component lifecycle and methods
http://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/
48. Example of lifecycle methods - update UI every 2s
class Example extends React.Component {
...
componentDidMount() { // Start 2 sec counter
const incFunc =
() => this.setState({ counter: this.state.counter + 1 });
this.timerID = setInterval(incFunc, 2 * 1000);
}
componentWillUnmount() { // Shutdown timer
clearInterval(this.timerID);
}
...
49. Stateless Components
● React Component can be function (not a class) if it only depends on props
function MyComponent(props) {
return <div>My name is {props.name}</div>;
}
Or using destructuring...
function MyComponent({name}) {
return <div>My name is {name}</div>;
}
● Much more concise than a class with render method
○ But what if you have one bit of state…
51. Introduction to React hooks
● Hooks are functions that let you “hook into” React state and
lifecycle features from function components.
o Hooks don’t work inside classes - they let you use React without classes
● Hooks allow us to use stateless (functional) components together
with all the more complex functionalities of class components.
● React provides a few built-in Hooks like useState, useEffect etc.
o You can also create your own Hooks to reuse stateful behavior between different
components
52. React Hooks - Add state to stateless components
● Inside of a "stateless" component add state: useState(initialStateValue)
○ useState parameter: initialStateValue - the initial value of the state
○ useState return value: An two element polymorphic array
■ 0th element - The current value of the state
■ 1st element - A set function to call (like this.setState)
● Example: a bit of state:
const [bit, setBit] = useState(0);
● How about lifecycle functions (e.g. componentDidUpdate, etc.)?
○ useEffect(lifeCycleFunction, dependency array)
■ useEffect parameter lifeCycleFunction - function to call when something changes
54. React Hooks Example - useState
import React, { useState} from 'react';
function Example() {
const [count, setCount] = useState(0);
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => setCount(count + 1)}>
Click me
</button>
</div>
);
}
55. ● UseEffect allows you to run a side effect on your component.
● The function passed to useEffect is a callback function. This will be called
after the component renders.
● The second argument is an array, called the dependencies array. This
array should include all of the values that our side effect relies upon.
import { useEffect } from 'react’;
function User({ name }) {
useEffect(() => {
document.title = name;
}, [name]);
return <h1>{name}</h1>;
}
React Hooks Example - useEffect
56. ● A typical use case is to fetch data once the component has been
mounted.
● Let's say we have a function called fetchData which is responsible
for that – our useEffect hook might look like this:
useEffect(() => { fetchData() }, [])
● Note: if the second argument (array) is empty, the effect will run
after every re-renders, otherwise it is only run when the variables in
the array has changed.
React Hooks Example - useEffect
57. Cleanup function in useEffect
● To use the cleanup function, we need to return a function from
within the useEffect function.
function Timer() {
const [time, setTime] = useState(0);
useEffect(() => {
let interval = setInterval(() => setTime(1), 1000);
return () => {
// setInterval cleared when component unmounts
clearInterval(interval);
}
}, []);
}
58. ● Passing information from parent to child: Use props (attributes)
<ChildComponent param={infoForChildComponent} />
● Passing information from child to parent: Callbacks
this.parentCallback = (infoFromChild) =>
{ /* processInfoFromChild */};
<ChildComponent callback={this.parentCallback}> />
● React Context (https://reactjs.org/docs/context.html)
○ Global variables for subtree of components
Communicating between React components
62. Using useState hook: input validation
function MyForm() {
const [inputValue, setInputValue] = useState('');
const [inputError, setInputError] = useState(null);
function handleInputChange(event) {
const value = event.target.value;
setInputValue(value);
if (value.length < 5) {
setInputError('Input must be at least 5 characters');
} else {
setInputError(null);
}
}
63. Using useState hook: input validation
function handleSubmit(event) {
event.preventDefault();
if (inputValue.length >= 5) {
// submit form
} else {
setInputError('Input must be at least 5 characters');
}
}
return (
<form onSubmit={handleSubmit}>
<label>
Fruit:
<input type="text" value={inputValue} onChange={handleInputChange} />
</label>
{inputError && <div style={{ color: 'red' }}>{inputError}</div>}
<button type="submit">Submit</button>
</form>
);
}
64. Uncontrolled component: Using useRef hook
● Use ref to get the current value of the input
● handleSubmit: process the input value
import { useRef } from "react";
export default function Uncontrolled() {
const selectRef = useRef(null);
const checkboxRef = useRef(null);
const inputRef = useRef(null);
function handleSubmit(event) {
event.preventDefault();
console.log("Input value:", inputRef.current.value);
console.log("Select value:", selectRef.current.value);
console.log("Checkbox value:", checkboxRef.current.checked);
}
66. Use component library: React hook form
● Need to install the library: npm install react-hook-form
● The useForm hook provides several functions and properties that you
can use to manage your form:
o register: This function is used to register form fields with React Hook Form.
o handleSubmit: This is used to handle form submissions. It takes a callback function
that is called when the form is submitted.
o errors: This represents an object containing any validation errors that occur when a
form is submitted.
o watch: This function is used to watch for changes to specific form fields. It takes an
array of form field names and returns the current value of those fields.
67. Use component library: React hook form
import { useForm } from 'react-hook-form';
function LoginForm() {
const { register, handleSubmit, formState: { errors } } = useForm();
const onSubmit = (data) => {
console.log(data);
};
return (
<form onSubmit={handleSubmit(onSubmit)}>
<label>Email</label>
<input type="email" {...register("email", { required: true, pattern: /^S+@S+$/i })} />
{errors.email && <p>Email is required and must be valid</p>}
<label>Password</label>
<input type="password" {...register("password", { required: true })} />
{errors.password && <p>Password is required</p>}
<button type="submit">Submit</button>
</form>
);
}
69. What is a API?
● API stands for Application Programming Interface. It enables the
exchange of information and functionality between different systems
o E.g between a website and a server or between different software applications
● An API functions as a waiter for software applications. It is a set of
rules that lets one program ask another for something it needs.
● Why are APIs important in web development?:
o Web applications need APIs to get data from various sources, like databases or
websites.
o APIs are a scalable option for managing high data or request volumes.
o Developers use APIs to leverage existing features and services. This saves them from
reinventing the wheel.
o They keep things safe by ensuring that only authorized individuals or programs can
use them.
o An API makes a website or mobile app more enjoyable to use by integrating data.
70. Restful API
● REST (Representational State Transfer) is an architectural style that defines a
set of constraints to be used when creating web services
o RESTful APIs follow several key principles, including statelessness, uniform interface, and
resource-based interactions.
● Anatomy of a RESTful API:
o A RESTful API consists of resources, each identified by a unique URI (Uniform Resource
Identifier).
o These resources can be manipulated using standard HTTP methods such as GET, POST, PUT,
PATCH, and DELETE.
o The API responses typically include data in a format like JSON (JavaScript Object Notation) or
XML (eXtensible Markup Language).
● RESTful API Endpoints: Endpoints are specific URLs that represent the
resources exposed by a RESTful API.
o For example, a simple blog API might have endpoints like /posts to retrieve all blog posts and
/posts/{id} to retrieve a specific post by its unique identifier.
71. How to Make API Requests in React
● Axios is a popular JavaScript library for making HTTP requests.
o Need to install axios library: npm install axios
● The Fetch API: A modern interface for making HTTP requests in the
browser
o The useEffect hook is used to fetch data when the component mounts
o The fetch function is used to make a GET request to the specified API endpoint
('https://api.example.com/posts’)
o the response is converted to JSON using response.json()
73. Making GET Requests: Enhance previous example
const ApiExample = () => {
const [data, setData] = useState([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
const fetchData = async () => {
try {
// Simulating a delay to show loading state
setTimeout(async () => {
const response = await fetch('https://api.example.com/posts?userId=1');
const result = await response.json();
setData(result);
setLoading(false);
}, 1000);
} catch (error) {
console.error('Error fetching data:', error);
setLoading(false);
}
};
fetchData();
}, []);
74. Making GET Requests: Enhance previous example
return (
<div>
<h1>API Data</h1>
{loading ? (
<p>Loading...</p>
) : (
<ul>
{data.map((item) => (
<li key={item.id}>{item.title}</li>
))}
</ul>
)}
</div>
);
};
● A loading state is introduced to provide feedback to users while the
data is being fetched
75. Handling Asynchronous Operations with async/await
● The use of async/await syntax makes asynchronous code more readable
and easier to work with
● The fetchData function is declared as an asynchronous function using the
async keyword. This allows the use of await inside the function
useEffect(() => {
const fetchData = async () => {
try {
const response = await fetch('https://api.example.com/posts?userId=1');
const result = await response.json();
setData(result);
setLoading(false);
} catch (error) {
console.error('Error fetching data:', error);
setLoading(false);
}
};
fetchData();
}, []);
77. Error Handling When Fetching Data
● The response.ok property is checked to determine if the HTTP request was
successful. If not, an error is thrown with information about the HTTP status
return (
<div>
<h1>API Data</h1>
{loading ? (
<p>Loading...</p>
) : error ? (
<p>{error}</p>
) : (
<ul>
{data.map((item) => (
<li key={item.id}>{item.title}</li>
))}
</ul>
)}
</div>
);
};
79. Display API Data in React Components
return (
<div>
<h2>API Data Display</h2>
{apiData ? (
// Render your component using the fetched data
<MyComponent data={apiData} />
) : (
// Render a loading state or placeholder
<p>Loading...</p>
)}
</div>
);
};
const MyComponent = ({ data }) => {
return (
<div>
<p>{data.message}</p>
{/* Render other components based on data */}
</div>
);
};
80. CRUD Operations with RESTful APIs: Creating Data
import React, { useState } from 'react';
import axios from 'axios’;
const CreateData = () => {
const [newData, setNewData] = useState('');
const handleCreate = async () => {
try {
await axios.post('https://api.example.com/data', { newData });
alert('Data created successfully!');
// Optionally, fetch and update the displayed data
} catch (error) {
console.error('Error creating data:', error);
}
};
return (
<div>
<h2>Create New Data</h2>
<input
type="text"
value={newData}
onChange={(e) => setNewData(e.target.value)}
/>
<button onClick={handleCreate}>Create</button>
</div>
);
};
export default CreateData;