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
Country | ISO_A2 | ISO_A3 | |
---|---|---|---|
Afghanistan | AF | AFG | |
Albania | AL | ALB | |
Algeria | DZ | DZA | |
Andorra | AD | AND | |
Angola | AO | AGO | |
Anguilla | AI | AIA | |
Antigua and Barbuda | AG | ATG | |
Argentina | AR | ARG | |
Armenia | AM | ARM |
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 React, { Component } from "react"; | |
class ProductData extends Component { | |
state = { | |
products: [] | |
}; | |
componentDidMount() { | |
getProducts().then(products => { | |
this.setState({ |
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 React, { Component } from "react"; | |
const withProductData = WrappedComponent => | |
class ProductData extends Component { | |
state = { | |
products: [] | |
}; | |
componentDidMount() { | |
getProducts().then(products => { |
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 MyContext = React.createContext(defaultValue); | |
<MyContext.Provider value={someValue}> | |
const value = useContext(MyContext); | |
// app.js | |
import React, {useState} from 'react'; | |
import Comp1 from './comp1'; | |
import { UserProvider } from './user' | |
import './App.css'; |
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
// The stores represent the ui state | |
class SearchStore { | |
@observable searchText; | |
@action | |
setSearchText = (searchText) => { | |
this.searchText = searchText | |
} | |
} |
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
// Bound Actions | |
import { observable } from "mobx"; | |
class Counter { | |
@observable count = 0; | |
@action.bound | |
increment() { | |
this.count++; | |
} | |
} | |
const counter = new Counter(); |
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
// EXAMPLE WITH CONTEXT | |
import React, {useContext, useState} from 'react'; | |
const AppContext = React.createContext(null); | |
const ContextProvider = ({children}) => { | |
const [counter, setCounter] = useState(0); | |
const contextValue = { | |
counter, | |
setCounter |
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
// Generators | |
// define | |
function* generator(i) { | |
yield i; | |
yield i + 10; | |
} | |
// init | |
const gen = generator(10); | |
// use |
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
// A simple promise that resolves after a given time | |
const timeOut = (t) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve(`Completed in ${t}`) | |
}, t) | |
}) | |
} | |
// Resolving a normal promise. | |
timeOut(1000) |
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
// codesandbox: https://codesandbox.io/s/react-codesandbox-o9e9f | |
import React from "react"; | |
import ReactDOM from "react-dom"; | |
function Logger(props) { | |
console.log(`${props.label} rendered`); | |
return null; // 여기서 반환되는 값은 부적절하다... | |
} |
OlderNewer