SlideShare a Scribd company logo
JavaScript, TypeScipt and React Native
Let's Talk about
JavaScript
> [] + []
> [] + []
""
> [] + {}
> [] + {}
'[object Object]'
> {} + []
> {} + []
0
> {} - {}
> {} - {}
NaN
JavaScript, TypeScipt and React Native
> true == "true"
true
> 1 == "one"
true
> 0 == "zero"
false
> true === "true"
false
Let's Talk about
JavaScript Types
JavaScript Types
string object function
number boolean undefined
Runtime typed
→ undefined is not a function
→ cannot read x of null/undefined
JavaScript, TypeScipt and React Native
Let's Talk about Type
Systems
Runtime typing
prop-types
→ Documents intended types of properties.
→ Only logs warnings.
prop-types
import PropTypes from 'prop-types';
const propTypes = {
optionalString: PropTypes.string,
requiredString: PropTypes.string.isRequired,
unionType: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.instanceOf(Message)
]),
}
class MyComponent extends React.Component {
render() {
// ... do things with the props
}
}
MyComponent.propTypes = {
...propTypes,
customProp: function(props, propName, componentName) {
if(not(valid)) {
return Error();
}
},
};
Let's Talk
about React
Native
Vernacular crash course
Component ~>
UIViewController | UIView
Does React Native run in a web view?
No.
Does React Native compile to native code?
No.
TypeScript
let y: number;
y = 2; // OK
y = "2"; // Type Error
let x = 2;
x = "2"; // Type Error
x = null; // Type Error
let x?: number;
x = null;
x = "Swift";
x = 2; // Type Error
Classes and
Interfaces
interface IRectangleConfig {
color?: string; // Nullable
width: number;
}
type SquareConfig = {
color?: string; // Nullable
width: number;
}
type idType = number;
type func = () => (x: string) => (p: boolean) => boolean;
type typedLiteral = "random-string";
type unionTypes = typedLiteral | "another-string";
type person = { name: string; age: number };
const personName = (p: person) => p.name
personName({name: "Jake", age: 42, class: "Magic Dog"})
class Greeter {
greeting: string;
constructor(message: string) {
this.greeting = message;
}
greet() {
return "Hello, " + this.greeting;
}
}
class RudeGreeter extends Greeter {
greeting: string;
constructor(message: string) {
this.greeting = message;
}
greet() {
return "Bugger off" + this.greeting;
}
}
Let's talk about
TypeScript in React
{
"compilerOptions": {
...,
"jsx": "react-native",
/* or "react" for web projects */
"moduleResolution": "node",
...,
}
}
JavaScript, TypeScipt and React Native
Install React Native Typings
npm install --save-dev @types/react
npm install --save-dev @types/react-native
JavaScript, TypeScipt and React Native
type TalkProps = {
id: string
title: string;
speakerName: string;
};
class Talk extends Component<TalkProps> {
public render() {
return (
<TextView>
{this.props.title} by
{this.props.speakerName}
</TextView>
);
}
}
import Talk from "./components/talk";
class App extends Component {
public render() {
const talk = {
id: "1234"
title: "Typing React";
speakerName: "Mitchell";
}
return (
<Talk
id={talk.id}
title={talk.title}
speakerName={talk.speakerName} />
);
}
}
import Talk from "./components/talk";
class App extends Component {
public render() {
const talk = {
id: "1234"
title: "Typing React";
speakerName: "Mitchell";
}
return (
<Talk
{...talk} />
);
}
}
type TalkState = {
time: int
};
class Talk extends Component<TalkProps, TalkState> {
public state: TalkState = { time: 0, };
constructor(props) { super(props);
setInterval(() =>
this.setState({ time: this.state.time + 1})
)
}
public render() {
return ( <TextView> {this.state.time} </TextView> );
}
}
OCamel/Reason
F# Fable
JS Wat's
https://www.destroyallsoftware.com/talks/wat

More Related Content

PDF
Madrid gug - sacando partido a las transformaciones ast de groovy
Iván López Martín
 
PDF
G3 Summit 2016 - Taking Advantage of Groovy Annotations
Iván López Martín
 
PDF
Mastering the MongoDB Shell
MongoDB
 
PDF
[2019-07] GraphQL in depth (serverside)
croquiscom
 
PDF
Mongophilly shell-2011-04-26
kreuter
 
PDF
Tour de Jackson: Forgotten Features of Jackson JSON processor
Tatu Saloranta
 
PPTX
OO in JavaScript
Gunjan Kumar
 
PDF
Comparing JSON Libraries - July 19 2011
sullis
 
Madrid gug - sacando partido a las transformaciones ast de groovy
Iván López Martín
 
G3 Summit 2016 - Taking Advantage of Groovy Annotations
Iván López Martín
 
Mastering the MongoDB Shell
MongoDB
 
[2019-07] GraphQL in depth (serverside)
croquiscom
 
Mongophilly shell-2011-04-26
kreuter
 
Tour de Jackson: Forgotten Features of Jackson JSON processor
Tatu Saloranta
 
OO in JavaScript
Gunjan Kumar
 
Comparing JSON Libraries - July 19 2011
sullis
 

What's hot (20)

PPTX
Groovy closures
Vijay Shukla
 
PDF
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
GeeksLab Odessa
 
PPTX
Constructor&method
Jani Harsh
 
PPTX
Lecture 2, c++(complete reference,herbet sheidt)chapter-12
Abu Saleh
 
PDF
Few simple-type-tricks in scala
Ruslan Shevchenko
 
PPTX
Jackson beyond JSON: XML, CSV
Tatu Saloranta
 
PDF
JavaScript objects and functions
Victor Verhaagen
 
PDF
Kotlin Delegates: Reduce the boilerplate
Dmytro Zaitsev
 
PPTX
Simple Jackson with DropWizard
Tatu Saloranta
 
PPTX
Lecture 4.2 c++(comlete reference book)
Abu Saleh
 
PPTX
Chapter ii(oop)
Chhom Karath
 
PDF
Object Oriented Programming in JavaScript
zand3rs
 
PDF
Functional Reactive Programming - RxSwift
Rodrigo Leite
 
PDF
Json.parse() in JavaScript
Ideas2IT Technologies
 
PPTX
JNI 使用淺談
KentPon Wang
 
PDF
From android/java to swift (3)
allanh0526
 
PPTX
Constructor ppt
Vinod Kumar
 
PPTX
AI Gaming - Azure Cognitive Services
AnweshBudhathoki
 
PPTX
Learn JS concepts by implementing jQuery
Wingify Engineering
 
PPTX
Constructors
shravani2191
 
Groovy closures
Vijay Shukla
 
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
GeeksLab Odessa
 
Constructor&method
Jani Harsh
 
Lecture 2, c++(complete reference,herbet sheidt)chapter-12
Abu Saleh
 
Few simple-type-tricks in scala
Ruslan Shevchenko
 
Jackson beyond JSON: XML, CSV
Tatu Saloranta
 
JavaScript objects and functions
Victor Verhaagen
 
Kotlin Delegates: Reduce the boilerplate
Dmytro Zaitsev
 
Simple Jackson with DropWizard
Tatu Saloranta
 
Lecture 4.2 c++(comlete reference book)
Abu Saleh
 
Chapter ii(oop)
Chhom Karath
 
Object Oriented Programming in JavaScript
zand3rs
 
Functional Reactive Programming - RxSwift
Rodrigo Leite
 
Json.parse() in JavaScript
Ideas2IT Technologies
 
JNI 使用淺談
KentPon Wang
 
From android/java to swift (3)
allanh0526
 
Constructor ppt
Vinod Kumar
 
AI Gaming - Azure Cognitive Services
AnweshBudhathoki
 
Learn JS concepts by implementing jQuery
Wingify Engineering
 
Constructors
shravani2191
 
Ad

Similar to JavaScript, TypeScipt and React Native (20)

PDF
Scala taxonomy
Radim Pavlicek
 
PDF
Grammarware Memes
Eelco Visser
 
PPT
Typescript - why it's awesome
Piotr Miazga
 
PDF
Functional programming ii
Prashant Kalkar
 
PDF
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
PDF
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
PDF
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
PDF
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
PPT
Understanding linq
Anand Kumar Rajana
 
PDF
Elm: give it a try
Eugene Zharkov
 
PDF
Python basic
Saifuddin Kaijar
 
PPTX
Object Oriented JavaScript
injulkarnilesh
 
PPTX
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
Alfonso Peletier
 
PPTX
Introduction to Client-Side Javascript
Julie Iskander
 
PPTX
Javascript
Gita Kriz
 
PDF
Introduction to scala
Michel Perez
 
PPTX
Scala
suraj_atreya
 
PPTX
Javascript 101
Shlomi Komemi
 
ODP
Dynamic Python
Chui-Wen Chiu
 
PDF
Introduction to Scala
Aleksandar Prokopec
 
Scala taxonomy
Radim Pavlicek
 
Grammarware Memes
Eelco Visser
 
Typescript - why it's awesome
Piotr Miazga
 
Functional programming ii
Prashant Kalkar
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
Understanding linq
Anand Kumar Rajana
 
Elm: give it a try
Eugene Zharkov
 
Python basic
Saifuddin Kaijar
 
Object Oriented JavaScript
injulkarnilesh
 
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
Alfonso Peletier
 
Introduction to Client-Side Javascript
Julie Iskander
 
Javascript
Gita Kriz
 
Introduction to scala
Michel Perez
 
Javascript 101
Shlomi Komemi
 
Dynamic Python
Chui-Wen Chiu
 
Introduction to Scala
Aleksandar Prokopec
 
Ad

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
PPTX
Coupa-Overview _Assumptions presentation
annapureddyn
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
PDF
Software Development Company | KodekX
KodekX
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
PPT
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
DevOps & Developer Experience Summer BBQ
AUGNYC
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
Coupa-Overview _Assumptions presentation
annapureddyn
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
Software Development Company | KodekX
KodekX
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
DevOps & Developer Experience Summer BBQ
AUGNYC
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 

JavaScript, TypeScipt and React Native