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 fetchMachine = Machine({ | |
id: "infinite-scroll", | |
initial: "idle", | |
context: { | |
page: 1, | |
size: 2, | |
total: 0, | |
keyword: "", | |
items: [] | |
}, |
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 { useState, useCallback } from "react"; | |
export function useSubmit(fun: Function): [Function, boolean] { | |
const [pending, setPending] = useState<boolean>(false); | |
const submit = useCallback( | |
(...args) => { | |
if (pending) return; | |
const res = fun.apply(this, args); |
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, { useRef, useMemo, useState, useCallback, useEffect } from "react"; | |
import ReactDOM from "react-dom"; | |
function applyHooks(hooks, initial, ...args) { | |
return hooks.reduce((prev, next) => { | |
const nextValue = next(prev, ...args); | |
if (typeof nextValue === "undefined") { | |
throw new Error("A hook just returned undefined! This is not allowed."); | |
} |
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
if (!process.env.NODE_ENV) { | |
process.env.NODE_ENV = 'development' | |
} | |
const clientEnv = require('react-scripts/config/env')().raw | |
console.log(clientEnv) |
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 Comp = () => { | |
const { getInputProps } = useImask({ | |
mask: [ | |
{ | |
mask: '000.000.000-00', | |
}, | |
{ | |
mask: '00.000.000/0000-00', | |
} | |
], |
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 fetchMachine = Machine({ | |
initial: 'images', | |
context: { | |
images: [], | |
expenses: [], | |
category: undefined | |
}, | |
states: { | |
images: { | |
on: { |
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
// TAP BACKEND | |
const appMachine = Machine( | |
{ | |
id: 'tap', | |
context: {}, | |
initial: 'bootstrap', | |
on: { | |
RESTART: 'bootstrap', | |
}, |
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
// TAP FRONTEND | |
const appMachine = Machine( | |
{ | |
id: 'tap', | |
initial: 'init', | |
context: {}, | |
on: { | |
RESTART: { | |
target: 'init', |
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
// INSTRUMENT | |
const fetchMachine = Machine( | |
{ | |
id: 'device', | |
initial: 'connection', | |
context: { | |
retries: 0 | |
}, | |
states: { |
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 S3Client = require('aws-sdk/clients/s3') | |
const sharp = require('sharp') | |
const ACCESS_KEY_ID = '' | |
const SECRET_ACCESS_KEY = '' | |
const REGION = '' | |
const BUCKET = '' | |
const PREFIX = '' | |
const CHUNK_SIZE = 500 | |
const FILTER = (filesName) => { |