This file contains hidden or 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' | |
| export interface ErrorBoundaryProps { | |
| children: React.ReactNode; | |
| fallback: React.ReactNode; | |
| onError?: (error: Error, errorInfo: React.ErrorInfo) => void | |
| } | |
| export interface ErrorBoundaryStates { | |
| error: Error | null; |
This file contains hidden or 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 Document, { | |
| DocumentContext, | |
| Head, | |
| Html, | |
| Main, | |
| NextScript, | |
| } from 'next/document' | |
| import { CSSProperties, ServerStyleSheet } from 'styled-components' | |
| import { AppContextProps } from 'YOUR APP CONTEXT' | |
| interface PageDocumentProps { |
This file contains hidden or 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
| export function buildDistanceInWordsLocale () { | |
| // tslint:disable:object-literal-sort-keys | |
| const distanceInWordsLocale:any = { | |
| lessThanXSeconds: { | |
| one: '방금 전', | |
| other: '방금 전' | |
| }, | |
| xSeconds: { | |
| one: '방금 전', |
This file contains hidden or 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 _ from "lodash"; | |
| import { AsyncStorage } from "react-native"; | |
| const setItem = (key: string, value: string) => { | |
| return new Promise((resolve, reject) => { | |
| AsyncStorage.multiSet([[key, value]], errors => { | |
| if (_.isEmpty(errors)) { | |
| resolve(true); | |
| return; | |
| } |
This file contains hidden or 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
| export const getValue = <T>(func: () => T, defaultValue: T):T => { | |
| try { | |
| return func(); | |
| } catch { | |
| return defaultValue; | |
| } | |
| } | |
| export function delay(seconds: number = 500) { | |
| return new Promise( |
This file contains hidden or 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
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | |
| WebView.setWebContentsDebuggingEnabled(true); | |
| } | |
| } |
This file contains hidden or 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
| // make a function to handle that error | |
| function handleError(fn) { | |
| return function (...params) { | |
| return fn(...params).catch(function (err) { | |
| // do something with the error! | |
| console.error('Opps!', err); | |
| }); | |
| } | |
| } |
This file contains hidden or 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
| function createLazily(msec = 1000) { | |
| let ongoing; | |
| return function* lazily(task, ...args) { | |
| if (ongoing && ongoing.isRunning()) { | |
| ongoing.cancel(); | |
| } | |
| ongoing = yield fork(function* doTask() { | |
| yield call(delay, msec); | |
| yield fork(task, ...args); | |
| }); |
This file contains hidden or 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
| interface Person { | |
| name: string; | |
| age: number; | |
| } | |
| function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] { | |
| return obj[key]; | |
| } | |
| function setProperty<T, K extends keyof T, V extends T[K]>(obj: T, key: K, value: V): void { |
This file contains hidden or 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
| class fetchResource = get => WrappedComponent => | |
| class extends React.Component { | |
| state = { resource: null }; | |
| componentDidMount() { | |
| get(this.props) | |
| .then(resource => this.setState({ resource })); | |
| } | |
| render() { |
NewerOlder