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
PDF
G3 Summit 2016 - Taking Advantage of Groovy Annotations
PDF
Mastering the MongoDB Shell
PDF
[2019-07] GraphQL in depth (serverside)
PDF
Mongophilly shell-2011-04-26
PDF
Tour de Jackson: Forgotten Features of Jackson JSON processor
PPTX
OO in JavaScript
PDF
Comparing JSON Libraries - July 19 2011
Madrid gug - sacando partido a las transformaciones ast de groovy
G3 Summit 2016 - Taking Advantage of Groovy Annotations
Mastering the MongoDB Shell
[2019-07] GraphQL in depth (serverside)
Mongophilly shell-2011-04-26
Tour de Jackson: Forgotten Features of Jackson JSON processor
OO in JavaScript
Comparing JSON Libraries - July 19 2011

What's hot (20)

PPTX
Groovy closures
PDF
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
PPTX
Constructor&method
PPTX
Lecture 2, c++(complete reference,herbet sheidt)chapter-12
PDF
Few simple-type-tricks in scala
PPTX
Jackson beyond JSON: XML, CSV
PDF
JavaScript objects and functions
PDF
Kotlin Delegates: Reduce the boilerplate
PPTX
Simple Jackson with DropWizard
PPTX
Lecture 4.2 c++(comlete reference book)
PPTX
Chapter ii(oop)
PDF
Object Oriented Programming in JavaScript
PDF
Functional Reactive Programming - RxSwift
PDF
Json.parse() in JavaScript
PPTX
JNI 使用淺談
PDF
From android/java to swift (3)
PPTX
Constructor ppt
PPTX
AI Gaming - Azure Cognitive Services
PPTX
Learn JS concepts by implementing jQuery
PPTX
Constructors
Groovy closures
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
Constructor&method
Lecture 2, c++(complete reference,herbet sheidt)chapter-12
Few simple-type-tricks in scala
Jackson beyond JSON: XML, CSV
JavaScript objects and functions
Kotlin Delegates: Reduce the boilerplate
Simple Jackson with DropWizard
Lecture 4.2 c++(comlete reference book)
Chapter ii(oop)
Object Oriented Programming in JavaScript
Functional Reactive Programming - RxSwift
Json.parse() in JavaScript
JNI 使用淺談
From android/java to swift (3)
Constructor ppt
AI Gaming - Azure Cognitive Services
Learn JS concepts by implementing jQuery
Constructors
Ad

Similar to JavaScript, TypeScipt and React Native (20)

PDF
Typescript is the best by Maxim Kryuk
PDF
Typescript is the best
PDF
Practical TypeScript
PDF
Static types on javascript?! Type checking approaches to ensure healthy appli...
PDF
Introduction to typescript
PPTX
Type Driven Development with TypeScript
PDF
Back to the Future with TypeScript
PDF
An Introduction to TypeScript
PPTX
Type script - advanced usage and practices
PDF
Types For Frontend Developers
PDF
Introduction to TypeScript
PDF
Power Leveling your TypeScript
PDF
Flow or Type - how to React to that?
PPTX
Introduction to TypeScript
PDF
React Native Evening
PDF
Strongly typed web applications by Adel Salakh
PDF
React Native One Day
PDF
Typescript For Beginners The Ultimate Guide Sufyan Bin Uzayr
PPTX
Getting started with typescript
PDF
TypeScript introduction to scalable javascript application
Typescript is the best by Maxim Kryuk
Typescript is the best
Practical TypeScript
Static types on javascript?! Type checking approaches to ensure healthy appli...
Introduction to typescript
Type Driven Development with TypeScript
Back to the Future with TypeScript
An Introduction to TypeScript
Type script - advanced usage and practices
Types For Frontend Developers
Introduction to TypeScript
Power Leveling your TypeScript
Flow or Type - how to React to that?
Introduction to TypeScript
React Native Evening
Strongly typed web applications by Adel Salakh
React Native One Day
Typescript For Beginners The Ultimate Guide Sufyan Bin Uzayr
Getting started with typescript
TypeScript introduction to scalable javascript application
Ad

Recently uploaded (20)

PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Electronic commerce courselecture one. Pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Machine learning based COVID-19 study performance prediction
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Assigned Numbers - 2025 - Bluetooth® Document
Encapsulation_ Review paper, used for researhc scholars
Chapter 3 Spatial Domain Image Processing.pdf
Network Security Unit 5.pdf for BCA BBA.
Electronic commerce courselecture one. Pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Programs and apps: productivity, graphics, security and other tools
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Empathic Computing: Creating Shared Understanding
Machine learning based COVID-19 study performance prediction
Building Integrated photovoltaic BIPV_UPV.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Mobile App Security Testing_ A Comprehensive Guide.pdf
Unlocking AI with Model Context Protocol (MCP)

JavaScript, TypeScipt and React Native