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
function wrapPromise(promise) { | |
let status = "pending"; | |
let result; | |
let suspender = promise.then( | |
r => { | |
status = "success"; | |
result = r; | |
}, | |
e => { | |
status = "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 { useState } from 'react' | |
const useForceUpdate = () => { | |
const [, setState] = useState() | |
return setState | |
} | |
export default useForceUpdate |
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 { ApolloLink } from 'apollo-link'; | |
const logLink = new ApolloLink((operation, forward) => { | |
console.time(operation.operationName); | |
return forward(operation).map(result => { | |
console.timeEnd(operation.operationName); | |
return result; | |
}); | |
}); |
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' | |
function Error({ statusCode }) { | |
return ( | |
<> | |
<h1>{statusCode}</h1> | |
<h2>This is the Next.js _error.js page</h2> | |
<p>Choose the status code by changing the url param above</p> | |
<p> | |
This page supports the 7.x.x status code range{' '} |
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 following code is experimental and might break in the future! | |
// Don't use it if you are using some kind of side-effect patterns like: Helmet, GraphQL or react-side-effect. | |
import { useRouter } from 'next/router' | |
function Home() { | |
const { | |
// `String` of the actual path (including the query) shows in the browser | |
asPath, | |
// `String` Current route |
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
/** | |
* Allows to repeatedly call | |
* an async code block | |
* | |
* @callback callback | |
* @callback [filterError] Allows to differentiate beween different type of errors | |
* @param {number} [maxRetries=Infinity] | |
*/ | |
function asyncRetry( | |
callback, |
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 toDataURL = url => fetch(url) | |
.then(response => response.blob()) | |
.then(blob => new Promise((resolve, reject) => { | |
const reader = new FileReader() | |
reader.onloadend = () => resolve(reader.result) | |
reader.onerror = reject | |
reader.readAsDataURL(blob) | |
})) |
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 Router from 'next/router' | |
import AppBarMD from 'material-ui/AppBar' | |
import Tabs, { Tab } from 'material-ui/Tabs' | |
const routes = [ | |
'/', | |
'/articles' | |
] |
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
// THIS IS JUST A POC. DO NOT USE THIS CODE! | |
module.exports = function babelPluginGenerateLanguageKatalog(api, options) { | |
const componentNames = ['FormattedMessage'] | |
const functionNames = ['formatMessage'] | |
const foundIds = new Set() | |
return { | |
inherits: require('babel-plugin-syntax-jsx'), |
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, { useImperativeHandle } from "react"; | |
import PropTypes from "prop-types"; | |
import TextField from "@material-ui/core/TextField"; | |
import { fade, useTheme } from "@material-ui/core/styles"; | |
function StripeInput(props) { | |
const { | |
component: Component, | |
inputRef, | |
/* eslint-disable no-unused-vars */ |