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, { forwardRef, useImperativeHandle, useRef } from 'react'; | |
const ChildComponent = forwardRef((props, ref) => { | |
useImperativeHandle(ref, () => ({ | |
handleAction() { | |
console.log('Action performed in Child'); | |
} | |
})); | |
return <div>Child Component</div>; |
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
let who = ['The dog','My grandma','His turtle','My bird']; | |
let action = ['ate','peed','crushed','broke']; | |
let what = ['my homework', 'the keys', 'the car']; | |
let when = ['before the class','right on time','when I finished','during my lunch','while I was praying', "yesterday"]; | |
function randomIndex (arr) { | |
return Math.floor(Math.random() * arr.length); | |
} |
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
// Functional Lenses | |
// | |
// A functional lens is an object that contains | |
// two functions, a getter and a setter. | |
// | |
// { | |
// getter: (obj) => any, | |
// setter: (obj, value) => obj | |
// } | |
// |
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 { isValidEmail } from 'lib/email' | |
import { withMongo } from 'lib/mongodb' | |
import { Db } from 'mongodb' | |
import { nanoid } from 'nanoid' | |
import { NextApiRequest, NextApiResponse } from 'next' | |
import nc from 'next-connect' | |
interface User { | |
id: string | |
email: string |
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 { Db, MongoClient, MongoClientOptions } from 'mongodb' | |
const MONGODB_URI = process.env.MONGO_DB_URL | |
const MONGODB_DB = process.env.MONGO_DB_NAME | |
let cached = global.mongo | |
if (!cached) { | |
cached = global.mongo = { conn: null, promise: 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 * as React from 'react' | |
import { NextPage } from 'next' | |
import { Container } from '@material-ui/core' | |
import { SubscribeHero } from 'components/SubscribeHero/SubscribeHero' | |
import { secureLoader, useAPIPost } from 'lib/api' | |
import useSWR from 'swr' | |
import { SubscriptionList, EmailSubscription } from 'components/SubscriptionList' | |
const URL = '/api/subscriptions' |
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 * as React from 'react' | |
import axios, { AxiosError } from 'axios' | |
export const useLoading = (): [boolean, (aPromise: Promise<any>) => any] => { | |
const [isLoading, setState] = React.useState<boolean>(false) | |
const mount = React.useRef(false) | |
React.useEffect(() => { | |
mount.current = 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
import React from 'react' | |
import { ComponentMeta } from '@storybook/react' | |
import { SubscriptionList } from './SubscriptionList' | |
import { Container } from '@material-ui/core' | |
export default { | |
title: 'Components/SubscriptionList', | |
component: SubscriptionList, | |
decorators: [ | |
Story => ( |
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 { | |
createStyles, | |
Paper, | |
Table, | |
TableBody, | |
TableCell, | |
TableContainer, | |
TableHead, | |
TableRow, | |
Theme, |
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 { isValidEmail } from 'lib/email' | |
import { NextApiRequest, NextApiResponse } from 'next' | |
import nc from 'next-connect' | |
// THIS IS IN MEMORY STATE | |
// will reset on every app restart | |
const subs = [] | |
export default nc<NextApiRequest, NextApiResponse>() | |
.get(async (req, res) => { |
NewerOlder