// makeStore.js
export default function makeStore(reducer, initialState) {
const DispatchContext = React.createContext()
const StoreContext = React.createContext()
function StoreProvider(props) {
const [store, dispatch] = React.useReducer(reducer, initialState)
// makeStore.tsx
export function makeStore<R extends React.Reducer<any, any>, I>(
reducer: R,
initialState: I & React.ReducerState<R>,
// initializer?: (arg: I & React.ReducerState<R>) => React.ReducerState<R>,
) {
const DispatchContext = React.createContext<null | React.Dispatch<
React.ReducerAction<R>
Implementation:
import React from 'react'
type Status = 'idle' | 'resolved' | 'rejected'
/**
* Copy text to the native clipboard using the `navigator.clipboard` API
* Adapted from https://www.benmvp.com/blog/copy-to-clipboard-react-custom-hook/
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
## Adapted from the following articles: | |
#- https://nodejs.org/en/docs/guides/nodejs-docker-webapp/ | |
#- https://medium.com/weekly-webtips/this-is-how-i-deploy-next-js-into-google-cloud-run-with-github-actions-1d7d2de9d203 | |
# Base image. | |
FROM node:14-alpine | |
# Create and change to the app directory. | |
WORKDIR /usr/app |
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
Dockerfile | |
.dockerignore | |
node_modules | |
npm-debug.log |
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
# Adapted from: https://github.com/google-github-actions/deploy-cloudrun/blob/main/.github/workflows/example-workflow.yaml | |
name: Build and Deploy to Cloud Run | |
on: | |
push: | |
branches: | |
- main | |
env: |
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
const files = await findFiles('/Users/aaronccasanova/projects', 'css') | |
console.log('files:', files) | |
/** | |
* Wraps the `find` command to recursively search for files of a given type. | |
* @param {string} path - Target directory to search | |
* @param {string} ext - File extension to search | |
* @returns {string[]} - Paths to all matching files | |
* |