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/
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 | |
* |
# 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: |
Dockerfile | |
.dockerignore | |
node_modules | |
npm-debug.log |
## 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 |
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/
// 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>
// 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)