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

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
 

Similar to JavaScript, TypeScipt and React Native (20)

PDF
Typescript is the best
GlobalLogic Ukraine
 
PDF
Typescript is the best by Maxim Kryuk
GlobalLogic Ukraine
 
PDF
Practical TypeScript
ldaws
 
PDF
Static types on javascript?! Type checking approaches to ensure healthy appli...
Arthur Puthin
 
PDF
Introduction to typescript
Mario Alexandro Santini
 
PPTX
Type Driven Development with TypeScript
Garth Gilmour
 
PDF
Back to the Future with TypeScript
Aleš Najmann
 
PDF
An Introduction to TypeScript
WrapPixel
 
PPTX
Type script - advanced usage and practices
Iwan van der Kleijn
 
PDF
Types For Frontend Developers
Jesse Williamson
 
PDF
Introduction to TypeScript
André Pitombeira
 
PDF
Power Leveling your TypeScript
Offirmo
 
PDF
Flow or Type - how to React to that?
Krešimir Antolić
 
PPTX
Introduction to TypeScript
Tomas Corral Casas
 
PDF
React Native Evening
Troy Miles
 
PDF
Strongly typed web applications by Adel Salakh
OdessaJS Conf
 
PDF
React Native One Day
Troy Miles
 
PDF
Typescript For Beginners The Ultimate Guide Sufyan Bin Uzayr
baielldebove
 
PPTX
Getting started with typescript
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
PDF
TypeScript introduction to scalable javascript application
Andrea Paciolla
 
Typescript is the best
GlobalLogic Ukraine
 
Typescript is the best by Maxim Kryuk
GlobalLogic Ukraine
 
Practical TypeScript
ldaws
 
Static types on javascript?! Type checking approaches to ensure healthy appli...
Arthur Puthin
 
Introduction to typescript
Mario Alexandro Santini
 
Type Driven Development with TypeScript
Garth Gilmour
 
Back to the Future with TypeScript
Aleš Najmann
 
An Introduction to TypeScript
WrapPixel
 
Type script - advanced usage and practices
Iwan van der Kleijn
 
Types For Frontend Developers
Jesse Williamson
 
Introduction to TypeScript
André Pitombeira
 
Power Leveling your TypeScript
Offirmo
 
Flow or Type - how to React to that?
Krešimir Antolić
 
Introduction to TypeScript
Tomas Corral Casas
 
React Native Evening
Troy Miles
 
Strongly typed web applications by Adel Salakh
OdessaJS Conf
 
React Native One Day
Troy Miles
 
Typescript For Beginners The Ultimate Guide Sufyan Bin Uzayr
baielldebove
 
Getting started with typescript
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
TypeScript introduction to scalable javascript application
Andrea Paciolla
 
Ad

Recently uploaded (20)

PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Ad

JavaScript, TypeScipt and React Native