SlideShare a Scribd company logo
USING REACT WITH METEOR
by Neha
What we will Learn
● Simple Rendering
● Updating
● Conditional Rendering
React JSX
JSX
● JSX is a syntax extension to JavaScript.
● Its tag syntax is neither a string nor HTML, e.g.
const element = <h1>Hello, world!</h1>;
● You can embed any JavaScript expression in JSX
● By wrapping it in curly braces, e.g.
○ {2 + 2}
JSX
function getGreeting(user) {
if (user) {
return <h1>Hello, {formatName(user)}!</h1>;
}
return <h1>Hello, Stranger.</h1>;
}
After compilation, JSX expressions become regular JS objects.
So we can:
● Use JSX inside if statements and for loops
● Assign it to variables
JSX
Specifying Attributes with JSX:
● String literals with quotes:
const element = <div className="container"></div>;
● JS expressions with curly braces:
const element = <img src={user.avatarUrl}></img>;
● React DOM uses camelCase property naming convention
Setup Meteor App
Setup Meteor App
● Create meteor app:
○ meteor create react-workshop
OR download starter files: https://goo.gl/gYHDUL
● Remove blaze and other packages:
○ meteor remove blaze-html-templates autopublish insecure
● Add React:
Adding React Component
Component: App.jsx
// Add: imports/ui/components/App.jsx
import React from 'react';
import { Meteor } from 'meteor/meteor';
export default class App extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div id="container">
{/* some html elements here */}
</div>
);
}
}
Simple Rendering
React DOM
What is React DOM?
● React DOM uses Virtual DOM concept
● It is used to manipulate the contents of our app view
● DOM-specific methods can be used at the top level of
our app
● Used via react-dom package
ReactDOM.render()
DOM Specific React Method:
● Renders a React element into the DOM in the supplied
container
● Return a reference to the component
● Controls the contents of the container node you pass
in.
Rendering an Element into the DOM
● Create a <div> in your HTML file:
○ <div id="app"></div>
● This is a "root" DOM node
● Everything inside it will be managed by React DOM.
client/main.html
<!-- client/main.html -->
<head>
<title>Player Stats</title>
</head>
<body>
<!-- React root node -->
<div id="app"></div>
<!-- React root node ends -->
</body>
client/main.js
// client/main.js
import { Meteor } from 'meteor/meteor';
import React from 'react';
import { render } from 'react-dom';
import App from '../imports/ui/components/App.jsx';
// Render simple react component at startup
Meteor.startup(() => {
render(<App />, document.getElementById('app'));
});
Rendering React Element
(Simple text render)
// imports/ui/components/App.jsx
// ...
render() {
const staticText = 'Meteor Noida';
return (
<div id="container">
<b>Static Text:</b> {staticText}
</div>
);
}
Run the Meteor
app!
Updating
Updating React Element
(Text box, update state)
Add State:
// imports/ui/components/App.jsx
// ...
constructor(props) {
super(props);
this.state = {
text: 'Hello Meteorites!',
};
}
// ...
Updating React Element
(Text box, update state)
Update render function:
// imports/ui/components/App.jsx
render() {
// ...
const { text } = this.state;
return (
// ...
<div id="container">
<b>Dynamic Text:</b> {text}
<br />
</div>
// ...
);
}
Updating React Element
(Text box, update state)
Add input box:
// imports/ui/components/App.jsx
<div id="container">
<b>Dynamic Text:</b> {text}
<br />
<input
type="text"
name="updateText"
value={text}
onChange={this.updateText.bind(this)}
/>
</div> See the React DOM
updates in action!
Updating React Element
(Text box, update state)
Add state handler:
// imports/ui/components/App.jsx
export default class App extends React.Component {
constructor(props) {
// ...
}
updateText(e) {
const text = e.target.value;
this.setState({ text });
}
render() {
// …
}
}
React Only Updates What's Necessary
React DOM:
● Compares the element and its children to the
previous one
● Only applies the DOM updates necessary
● To bring the DOM to the desired state.
Conditional Rendering
Conditional Rendering
(Checkbox to show text)
// imports/ui/components/App.jsx
constructor(props) {
super(props);
this.state = {
text: 'Hello Meteorites!',
show: true,
};
}
Conditional Rendering
(Checkbox to show text)
render() {
const { text, show } = this.state;
// ...
return (
<div id="container">
{/* ... */}
{/* Checkbox to show input text box */}
<b>Show Input Box:</b>
<input
type="checkbox"
name="showInputBox"
checked={show}
onChange={this.toggleInputBox.bind(this)}
/>
<br /><br />
{/* ... */}
</div>
);
}
}
Conditional Rendering
(Checkbox to show text)
// State handler for checkbox
toggleInputBox(e) {
const show = e.target.checked;
this.setState({ show });
}
Conditional Rendering
(Checkbox to show text)
<div id="container">
{/* ... */}
{/* Conditionally render input text box based on checkbox value */}
{
show
? <div>
<input
type="text"
name="updateText"
value={text}
onChange={this.updateText.bind(this)}
/>
<br />
</div>
: null
}
{/* ... */}
</div>
See the Conditional
Rendering in action!

More Related Content

What's hot

React with Redux
React with ReduxReact with Redux
React with Redux
Stanimir Todorov
 
REACT.JS : Rethinking UI Development Using JavaScript
REACT.JS : Rethinking UI Development Using JavaScriptREACT.JS : Rethinking UI Development Using JavaScript
REACT.JS : Rethinking UI Development Using JavaScript
Deepu S Nath
 
React for Dummies
React for DummiesReact for Dummies
React for Dummies
Mitch Chen
 
Repetition is bad, repetition is bad.
Repetition is bad, repetition is bad.Repetition is bad, repetition is bad.
Repetition is bad, repetition is bad.
Michele Giacobazzi
 
Workshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsWorkshop 3: JavaScript build tools
Workshop 3: JavaScript build tools
Visual Engineering
 
React.js and Redux overview
React.js and Redux overviewReact.js and Redux overview
React.js and Redux overview
Alex Bachuk
 
7\9 SSIS 2008R2_Training - Script Task
7\9 SSIS 2008R2_Training - Script Task7\9 SSIS 2008R2_Training - Script Task
7\9 SSIS 2008R2_Training - Script Task
Pramod Singla
 
Mobile Day - React Native
Mobile Day - React NativeMobile Day - React Native
Mobile Day - React Native
Software Guru
 
How to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescriptHow to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescript
Katy Slemon
 
React redux
React reduxReact redux
React redux
Michel Perez
 
Async JavaScript Unit Testing
Async JavaScript Unit TestingAsync JavaScript Unit Testing
Async JavaScript Unit Testing
Mihail Gaberov
 
Asyc flow control with javascript generators - redux-saga
Asyc flow control with javascript generators - redux-sagaAsyc flow control with javascript generators - redux-saga
Asyc flow control with javascript generators - redux-saga
Pedro Solá
 
Let's Redux!
Let's Redux!Let's Redux!
Let's Redux!
Joseph Chiang
 
Rapid development tools for java ee 8 [tut2998]
Rapid development tools for java ee 8 [tut2998]Rapid development tools for java ee 8 [tut2998]
Rapid development tools for java ee 8 [tut2998]
Payara
 
Sqladria 2009 SRC
Sqladria 2009 SRCSqladria 2009 SRC
Sqladria 2009 SRC
tepsum
 
Stay with React.js in 2020
Stay with React.js in 2020Stay with React.js in 2020
Stay with React.js in 2020
Jerry Liao
 
PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...
PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...
PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...
Alessandro Molina
 
Rapid Development Tools for Java EE 8 [TUT2998]
Rapid Development Tools for Java EE 8 [TUT2998]Rapid Development Tools for Java EE 8 [TUT2998]
Rapid Development Tools for Java EE 8 [TUT2998]
Gaurav Gupta
 
Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2Alessandro Molina
 
Redux workshop
Redux workshopRedux workshop
Redux workshop
Imran Sayed
 

What's hot (20)

React with Redux
React with ReduxReact with Redux
React with Redux
 
REACT.JS : Rethinking UI Development Using JavaScript
REACT.JS : Rethinking UI Development Using JavaScriptREACT.JS : Rethinking UI Development Using JavaScript
REACT.JS : Rethinking UI Development Using JavaScript
 
React for Dummies
React for DummiesReact for Dummies
React for Dummies
 
Repetition is bad, repetition is bad.
Repetition is bad, repetition is bad.Repetition is bad, repetition is bad.
Repetition is bad, repetition is bad.
 
Workshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsWorkshop 3: JavaScript build tools
Workshop 3: JavaScript build tools
 
React.js and Redux overview
React.js and Redux overviewReact.js and Redux overview
React.js and Redux overview
 
7\9 SSIS 2008R2_Training - Script Task
7\9 SSIS 2008R2_Training - Script Task7\9 SSIS 2008R2_Training - Script Task
7\9 SSIS 2008R2_Training - Script Task
 
Mobile Day - React Native
Mobile Day - React NativeMobile Day - React Native
Mobile Day - React Native
 
How to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescriptHow to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescript
 
React redux
React reduxReact redux
React redux
 
Async JavaScript Unit Testing
Async JavaScript Unit TestingAsync JavaScript Unit Testing
Async JavaScript Unit Testing
 
Asyc flow control with javascript generators - redux-saga
Asyc flow control with javascript generators - redux-sagaAsyc flow control with javascript generators - redux-saga
Asyc flow control with javascript generators - redux-saga
 
Let's Redux!
Let's Redux!Let's Redux!
Let's Redux!
 
Rapid development tools for java ee 8 [tut2998]
Rapid development tools for java ee 8 [tut2998]Rapid development tools for java ee 8 [tut2998]
Rapid development tools for java ee 8 [tut2998]
 
Sqladria 2009 SRC
Sqladria 2009 SRCSqladria 2009 SRC
Sqladria 2009 SRC
 
Stay with React.js in 2020
Stay with React.js in 2020Stay with React.js in 2020
Stay with React.js in 2020
 
PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...
PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...
PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...
 
Rapid Development Tools for Java EE 8 [TUT2998]
Rapid Development Tools for Java EE 8 [TUT2998]Rapid Development Tools for Java EE 8 [TUT2998]
Rapid Development Tools for Java EE 8 [TUT2998]
 
Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2
 
Redux workshop
Redux workshopRedux workshop
Redux workshop
 

Similar to Using react with meteor

Understanding React JSX_ A Beginner's Guide
Understanding React JSX_ A Beginner's GuideUnderstanding React JSX_ A Beginner's Guide
Understanding React JSX_ A Beginner's Guide
Elightwalk Technology PVT. LTD.
 
React outbox
React outboxReact outbox
React outbox
Angela Lehru
 
React js
React jsReact js
React js
Rajesh Kolla
 
React JSX.pptx
React JSX.pptxReact JSX.pptx
React JSX.pptx
avinashB60
 
React & Redux for noobs
React & Redux for noobsReact & Redux for noobs
React & Redux for noobs
[T]echdencias
 
Let's react - Meetup
Let's react - MeetupLet's react - Meetup
Let's react - Meetup
RAJNISH KATHAROTIYA
 
Simple React Todo List
Simple React Todo ListSimple React Todo List
Simple React Todo List
Ritesh Chaudhari
 
Academy PRO: React JS
Academy PRO: React JSAcademy PRO: React JS
Academy PRO: React JS
Binary Studio
 
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Luciano Mammino
 
Getting Started with React v16
Getting Started with React v16Getting Started with React v16
Getting Started with React v16
Benny Neugebauer
 
SenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark Brocato
SenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark BrocatoSenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark Brocato
SenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark Brocato
Sencha
 
ReactJS
ReactJSReactJS
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
Varun Raj
 
Custom gutenberg block development in react
Custom gutenberg block development in reactCustom gutenberg block development in react
Custom gutenberg block development in react
Imran Sayed
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
Ignacio Martín
 
React js t2 - jsx
React js   t2 - jsxReact js   t2 - jsx
React js t2 - jsx
Jainul Musani
 
React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today
Nitin Tyagi
 
How to create components in react js
How to create components in react jsHow to create components in react js
How to create components in react js
BOSC Tech Labs
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
Matteo Manchi
 
React/Redux
React/ReduxReact/Redux
React/Redux
Durgesh Vaishnav
 

Similar to Using react with meteor (20)

Understanding React JSX_ A Beginner's Guide
Understanding React JSX_ A Beginner's GuideUnderstanding React JSX_ A Beginner's Guide
Understanding React JSX_ A Beginner's Guide
 
React outbox
React outboxReact outbox
React outbox
 
React js
React jsReact js
React js
 
React JSX.pptx
React JSX.pptxReact JSX.pptx
React JSX.pptx
 
React & Redux for noobs
React & Redux for noobsReact & Redux for noobs
React & Redux for noobs
 
Let's react - Meetup
Let's react - MeetupLet's react - Meetup
Let's react - Meetup
 
Simple React Todo List
Simple React Todo ListSimple React Todo List
Simple React Todo List
 
Academy PRO: React JS
Academy PRO: React JSAcademy PRO: React JS
Academy PRO: React JS
 
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
 
Getting Started with React v16
Getting Started with React v16Getting Started with React v16
Getting Started with React v16
 
SenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark Brocato
SenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark BrocatoSenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark Brocato
SenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark Brocato
 
ReactJS
ReactJSReactJS
ReactJS
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
 
Custom gutenberg block development in react
Custom gutenberg block development in reactCustom gutenberg block development in react
Custom gutenberg block development in react
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
 
React js t2 - jsx
React js   t2 - jsxReact js   t2 - jsx
React js t2 - jsx
 
React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today
 
How to create components in react js
How to create components in react jsHow to create components in react js
How to create components in react js
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
 
React/Redux
React/ReduxReact/Redux
React/Redux
 

More from NodeXperts

ECMA Script
ECMA ScriptECMA Script
ECMA Script
NodeXperts
 
Apollo Server IV
Apollo Server IVApollo Server IV
Apollo Server IV
NodeXperts
 
React Context API
React Context APIReact Context API
React Context API
NodeXperts
 
Devops - Microservice and Kubernetes
Devops - Microservice and KubernetesDevops - Microservice and Kubernetes
Devops - Microservice and Kubernetes
NodeXperts
 
Introduction to EC2 (AWS)
Introduction to EC2 (AWS)Introduction to EC2 (AWS)
Introduction to EC2 (AWS)
NodeXperts
 
Reactive Application Using METEOR
Reactive Application Using METEORReactive Application Using METEOR
Reactive Application Using METEOR
NodeXperts
 
Apollo server II
Apollo server IIApollo server II
Apollo server II
NodeXperts
 
Apollo Server
Apollo ServerApollo Server
Apollo Server
NodeXperts
 
Apollo Server III
Apollo Server IIIApollo Server III
Apollo Server III
NodeXperts
 
Getting Reactive Data
Getting Reactive DataGetting Reactive Data
Getting Reactive Data
NodeXperts
 
State, Life cycle, Methods & Events
State, Life cycle, Methods & Events State, Life cycle, Methods & Events
State, Life cycle, Methods & Events
NodeXperts
 
Refs in react
Refs in reactRefs in react
Refs in react
NodeXperts
 
Flow router, components and props
Flow router, components and propsFlow router, components and props
Flow router, components and props
NodeXperts
 
Introduction to Reactjs
Introduction to ReactjsIntroduction to Reactjs
Introduction to Reactjs
NodeXperts
 
Mobile apps using meteor - Part 1
Mobile apps using meteor - Part 1Mobile apps using meteor - Part 1
Mobile apps using meteor - Part 1
NodeXperts
 
Microservice architecture : Part 1
Microservice architecture : Part 1Microservice architecture : Part 1
Microservice architecture : Part 1
NodeXperts
 
Reactive web applications using MeteorJS
Reactive web applications using MeteorJSReactive web applications using MeteorJS
Reactive web applications using MeteorJS
NodeXperts
 
Improving build solutions dependency management with webpack
Improving build solutions  dependency management with webpackImproving build solutions  dependency management with webpack
Improving build solutions dependency management with webpack
NodeXperts
 
Meteor workshop
Meteor workshopMeteor workshop
Meteor workshop
NodeXperts
 
Introduction to meteor
Introduction to meteorIntroduction to meteor
Introduction to meteor
NodeXperts
 

More from NodeXperts (20)

ECMA Script
ECMA ScriptECMA Script
ECMA Script
 
Apollo Server IV
Apollo Server IVApollo Server IV
Apollo Server IV
 
React Context API
React Context APIReact Context API
React Context API
 
Devops - Microservice and Kubernetes
Devops - Microservice and KubernetesDevops - Microservice and Kubernetes
Devops - Microservice and Kubernetes
 
Introduction to EC2 (AWS)
Introduction to EC2 (AWS)Introduction to EC2 (AWS)
Introduction to EC2 (AWS)
 
Reactive Application Using METEOR
Reactive Application Using METEORReactive Application Using METEOR
Reactive Application Using METEOR
 
Apollo server II
Apollo server IIApollo server II
Apollo server II
 
Apollo Server
Apollo ServerApollo Server
Apollo Server
 
Apollo Server III
Apollo Server IIIApollo Server III
Apollo Server III
 
Getting Reactive Data
Getting Reactive DataGetting Reactive Data
Getting Reactive Data
 
State, Life cycle, Methods & Events
State, Life cycle, Methods & Events State, Life cycle, Methods & Events
State, Life cycle, Methods & Events
 
Refs in react
Refs in reactRefs in react
Refs in react
 
Flow router, components and props
Flow router, components and propsFlow router, components and props
Flow router, components and props
 
Introduction to Reactjs
Introduction to ReactjsIntroduction to Reactjs
Introduction to Reactjs
 
Mobile apps using meteor - Part 1
Mobile apps using meteor - Part 1Mobile apps using meteor - Part 1
Mobile apps using meteor - Part 1
 
Microservice architecture : Part 1
Microservice architecture : Part 1Microservice architecture : Part 1
Microservice architecture : Part 1
 
Reactive web applications using MeteorJS
Reactive web applications using MeteorJSReactive web applications using MeteorJS
Reactive web applications using MeteorJS
 
Improving build solutions dependency management with webpack
Improving build solutions  dependency management with webpackImproving build solutions  dependency management with webpack
Improving build solutions dependency management with webpack
 
Meteor workshop
Meteor workshopMeteor workshop
Meteor workshop
 
Introduction to meteor
Introduction to meteorIntroduction to meteor
Introduction to meteor
 

Recently uploaded

Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 

Recently uploaded (20)

Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 

Using react with meteor

  • 1. USING REACT WITH METEOR by Neha
  • 2. What we will Learn ● Simple Rendering ● Updating ● Conditional Rendering
  • 4. JSX ● JSX is a syntax extension to JavaScript. ● Its tag syntax is neither a string nor HTML, e.g. const element = <h1>Hello, world!</h1>; ● You can embed any JavaScript expression in JSX ● By wrapping it in curly braces, e.g. ○ {2 + 2}
  • 5. JSX function getGreeting(user) { if (user) { return <h1>Hello, {formatName(user)}!</h1>; } return <h1>Hello, Stranger.</h1>; } After compilation, JSX expressions become regular JS objects. So we can: ● Use JSX inside if statements and for loops ● Assign it to variables
  • 6. JSX Specifying Attributes with JSX: ● String literals with quotes: const element = <div className="container"></div>; ● JS expressions with curly braces: const element = <img src={user.avatarUrl}></img>; ● React DOM uses camelCase property naming convention
  • 8. Setup Meteor App ● Create meteor app: ○ meteor create react-workshop OR download starter files: https://goo.gl/gYHDUL ● Remove blaze and other packages: ○ meteor remove blaze-html-templates autopublish insecure ● Add React:
  • 10. Component: App.jsx // Add: imports/ui/components/App.jsx import React from 'react'; import { Meteor } from 'meteor/meteor'; export default class App extends React.Component { constructor(props) { super(props); } render() { return ( <div id="container"> {/* some html elements here */} </div> ); } }
  • 12. React DOM What is React DOM? ● React DOM uses Virtual DOM concept ● It is used to manipulate the contents of our app view ● DOM-specific methods can be used at the top level of our app ● Used via react-dom package
  • 13. ReactDOM.render() DOM Specific React Method: ● Renders a React element into the DOM in the supplied container ● Return a reference to the component ● Controls the contents of the container node you pass in.
  • 14. Rendering an Element into the DOM ● Create a <div> in your HTML file: ○ <div id="app"></div> ● This is a "root" DOM node ● Everything inside it will be managed by React DOM.
  • 15. client/main.html <!-- client/main.html --> <head> <title>Player Stats</title> </head> <body> <!-- React root node --> <div id="app"></div> <!-- React root node ends --> </body>
  • 16. client/main.js // client/main.js import { Meteor } from 'meteor/meteor'; import React from 'react'; import { render } from 'react-dom'; import App from '../imports/ui/components/App.jsx'; // Render simple react component at startup Meteor.startup(() => { render(<App />, document.getElementById('app')); });
  • 17. Rendering React Element (Simple text render) // imports/ui/components/App.jsx // ... render() { const staticText = 'Meteor Noida'; return ( <div id="container"> <b>Static Text:</b> {staticText} </div> ); } Run the Meteor app!
  • 19. Updating React Element (Text box, update state) Add State: // imports/ui/components/App.jsx // ... constructor(props) { super(props); this.state = { text: 'Hello Meteorites!', }; } // ...
  • 20. Updating React Element (Text box, update state) Update render function: // imports/ui/components/App.jsx render() { // ... const { text } = this.state; return ( // ... <div id="container"> <b>Dynamic Text:</b> {text} <br /> </div> // ... ); }
  • 21. Updating React Element (Text box, update state) Add input box: // imports/ui/components/App.jsx <div id="container"> <b>Dynamic Text:</b> {text} <br /> <input type="text" name="updateText" value={text} onChange={this.updateText.bind(this)} /> </div> See the React DOM updates in action!
  • 22. Updating React Element (Text box, update state) Add state handler: // imports/ui/components/App.jsx export default class App extends React.Component { constructor(props) { // ... } updateText(e) { const text = e.target.value; this.setState({ text }); } render() { // … } }
  • 23. React Only Updates What's Necessary React DOM: ● Compares the element and its children to the previous one ● Only applies the DOM updates necessary ● To bring the DOM to the desired state.
  • 25. Conditional Rendering (Checkbox to show text) // imports/ui/components/App.jsx constructor(props) { super(props); this.state = { text: 'Hello Meteorites!', show: true, }; }
  • 26. Conditional Rendering (Checkbox to show text) render() { const { text, show } = this.state; // ... return ( <div id="container"> {/* ... */} {/* Checkbox to show input text box */} <b>Show Input Box:</b> <input type="checkbox" name="showInputBox" checked={show} onChange={this.toggleInputBox.bind(this)} /> <br /><br /> {/* ... */} </div> ); } }
  • 27. Conditional Rendering (Checkbox to show text) // State handler for checkbox toggleInputBox(e) { const show = e.target.checked; this.setState({ show }); }
  • 28. Conditional Rendering (Checkbox to show text) <div id="container"> {/* ... */} {/* Conditionally render input text box based on checkbox value */} { show ? <div> <input type="text" name="updateText" value={text} onChange={this.updateText.bind(this)} /> <br /> </div> : null } {/* ... */} </div> See the Conditional Rendering in action!

Editor's Notes

  1. Applications built with React usually have a single root DOM node. To render a React element into a root DOM node, pass both to ReactDOM.render() Now we will see how this is done...