View getNewMission.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_getNewRocket() { | |
this.setState({ | |
rocketName: mission.rocket.rocket_name, | |
missionName: mission.mission_name, | |
missionLogo: mission.links.mission_patch_small, | |
launchImg: mission.links.flickr_images[Math.floor(Math.random() * 5)], | |
missionDetails: mission.details, | |
flightNumber: mission.flight_number, | |
missionId: mission.mission_id, | |
launchDate: new Date(mission.launch_date_unix * 1000).toDateString(), |
View getNewMission.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_getNewMission() { | |
this.setState({ | |
// Use this to change the state values when the button is clicked. | |
appTitle: 'SpaceX Launches', | |
launchImg: require('./assets/2013_-_9_falcon_9_ses_launch-4.jpg'), | |
rocketName: '', | |
missionName: '', | |
missionLogo: require('./assets/mission-logo.png'), | |
missionDetails: '', | |
missionSuccess: false, |
View state.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type State = { | |
appTitle: string; | |
launchImg: string; | |
rocketName: string; | |
missionName: string; | |
missionLogo: string; | |
missionDetails: string; | |
missionSuccess: boolean; | |
flightNumber: number; | |
missionId: string; |
View stateType.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type State = { | |
appTitle: string; | |
launchImg: string; | |
rocketName: string; | |
missionName: string; | |
missionLogo: string; | |
missionDetails: string; | |
missionSuccess: boolean; | |
flightNumber: number; | |
missionId: string; |
View stateType.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type State = { | |
appTitle: 'SpaceX Launches'; | |
launchImg: ''; | |
rocketName: ''; | |
missionName: ''; | |
missionLogo: ''; | |
missionDetails: ''; | |
missionSuccess: false; | |
flightNumber: 0; | |
missionId: ''; |
View RocketApp.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import './styles.css'; | |
// Rocket Info | |
import { mission } from './data/rockets'; | |
import 'bootstrap/dist/css/bootstrap.css'; | |
// Create a State type below this line | |
type State = {} | |
export default class RocketApp extends React.Component<{}, {}> {...} |
View personAge.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bob: string = 'Bob'; | |
const bobsAge: number = 20; | |
function personAge(person: string, age: number) { | |
return `${person} is ${age} years old.`; | |
} | |
personAge(bob, bobsAge); |
View tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"lib": ["es6"], | |
"target": "es6", | |
"module": "commonjs", | |
"noImplicitAny": true, | |
"noImplicitThis": true, | |
"strictNullChecks": false, | |
"strictFunctionTypes": true, | |
"forceConsistentCasingInFileNames": true |
View tstooling.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let myNumber: number = 10; | |
let myString: string = 'this is a string'; | |
const badMath = (x: number, y: number) => { | |
return x * y; | |
} | |
badMath(myNumber, myString) /** | |
* error TS2345: Argument of type 'string' | |
* is not assignable to parameter of type 'number'. |
View typeofExample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let myNumber = 10; | |
let myString = 'this is a string'; | |
if (typeof myNumber === 'string') { | |
console.log('This is a string, not a number.') | |
} else { | |
console.log('This is a number'); | |
} | |
const badMath = (x, y) => { |
NewerOlder