Type 'from' in the editor and...
View typescript.md
What even is TypeScript?
JavaScript + Types = Typescript
TypeScript as a compilter
npm i -g typescript
./node_modules/.bin/tsc
View vershion.sh
#!/bin/sh | |
set -e | |
POSITIONAL=() | |
while [[ $# -gt 0 ]] | |
do | |
key="$1" | |
case $key in |
View price.tsx
import * as React from "react"; | |
import formatPrice from "../utils/formatPrice"; | |
export interface IPriceProps { | |
num: number; | |
symbol: "$" | "€" | "£"; | |
} | |
const Price: React.SFC<IPriceProps> = ({ | |
num, |
View formatPriceJsDoc.ts
// @ts-check | |
/** | |
* Format a price | |
* @param num {number} The price | |
* @param symbol {string} The currency symbol | |
*/ | |
const formatPrice = (num, symbol = "$") => | |
`${symbol}${num.toFixed(2)}`; | |
formatPrice("1234"); |
View formatPrice.ts
const formatPrice = (num: number, symbol = "$": string) => | |
`${symbol}${num.toFixed(2)}`; formatPrice("1234"); | |
// num.toFixed is not a function |
View formatPrice.js
const formatPrice = (num, symbol = "$") => | |
`${symbol}${num.toFixed(2)}`; formatPrice("1234"); |
View launch.json
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "node", | |
"request": "launch", | |
"name": "Run tests", | |
"program": "${workspaceRoot}/node_modules/.bin/jest" | |
}, | |
{ |
View react-lifecycle.md
Name of thing | Sorta like... | Mounted? | Can you even setState? | What would you say... ya do here? |
---|---|---|---|---|
constructor | initialize() | nope | nope | init stuff NO side effects |
componentWillMount | beforeDomReady() | nope | yeah but don't | Only needed in createClass now use constructor for most things |
render | render | nope | please no | render stuff and don't set any state please |
componentDidMount | domReady() | yup | yup | DOM is a go init jQuery plugins dispatch stuff |
componentWillReceiveProps | onChange() | yup | yup |
NewerOlder