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 from "react"; | |
import pathToRegexp from "path-to-regexp"; | |
function Home() { | |
return <h1>Home</h1>; | |
} | |
function About() { | |
return <h1>About</h1>; | |
} |
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 Google Cloud SDK on Travis is pretty old (2014). So if | |
# you want to use an up-to-date version, you have to install | |
# your own. This config is the bare minimum you'll need to | |
# get an updated version of the SDK + kubectl. | |
cache: | |
directories: | |
# We cache the SDK so we don't have to download it again on subsequent builds. | |
- $HOME/google-cloud-sdk | |
services: | |
# Include the docker service so you can roll your own images. |
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
FROM node:8 | |
WORKDIR /home/node/app | |
ADD https://github.com/Yelp/dumb-init/releases/download/v1.1.1/dumb-init_1.1.1_amd64 /usr/local/bin/dumb-init | |
RUN chmod +x /usr/local/bin/dumb-init | |
COPY package.json yarn.lock ./ | |
RUN yarn --pure-lockfile | |
COPY . . |
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 from "react"; | |
import ReactDOM from "react-dom"; | |
import PropTypes from "prop-types"; | |
document.body.style.background = ` | |
linear-gradient(135deg, | |
#1e5799 0%, | |
#2989d8 50%, | |
#207cca 51%, | |
#7db9e8 100% |
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 throttle from 'lodash/throttle' | |
import React, { PropTypes } from 'react' | |
const ThrottledInput = React.createClass({ | |
propTypes: { | |
delay: PropTypes.number | |
}, | |
getDefaultProps() { | |
return { |
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 element = ( | |
<div> | |
{currentPage === 'signin' ? ( | |
<SignInPage/> | |
) : currentPage === 'welcome' ? ( | |
<WelcomePage/> | |
) : currentPage === 'about' ? ( | |
<AboutPage/> | |
) : ( | |
<DefaultPage/> |
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 { useEffect, useRef } from 'react'; | |
function getItem(storage, key) { | |
const value = storage.getItem(key); | |
if (!value) return null; | |
try { | |
return JSON.parse(value); | |
} catch (error) { |
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 { useRef, useState } from 'react' | |
function useUndo([state, setState]) { | |
const history = useRef([state]) | |
const [index, setIndex] = useState(0) | |
function undo() { | |
setIndex(Math.max(index - 1, 0)) | |
} | |
function redo() { |
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 from "react"; | |
export type ColorScheme = "light" | "dark"; | |
export default function useColorSchemePreference( | |
defaultColorScheme: ColorScheme = "light" | |
) { | |
let darkQuery = "(prefers-color-scheme: dark)"; | |
let [colorScheme, setColorScheme] = React.useState<ColorScheme>( | |
typeof window === "object" && window.matchMedia |
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
/** | |
* Registers the given callback to be called in the node.js callback | |
* style, with error as the first argument, when the promise resolves. | |
* | |
* Also, returns a function that may be used to prevent the callback | |
* from ever being called. Calling the returned function is synonymous | |
* with saying "I no longer care about the resolution of this promise, | |
* even if it fails." | |
* | |
* Since there is no provision in the promise spec for cancel/abort |