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 { Dispatch, SetStateAction, useEffect, useState, useCallback } from 'react'; | |
| type SetValue<T> = Dispatch<SetStateAction<T>>; | |
| type CleanValue = () => void; | |
| type CustomEventDetail = { key: string }; | |
| const CUSTOM_STORAGE_EVENT = 'webshop:storage'; | |
| declare global { |
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
| /** | |
| * Typed Web Worker. | |
| * | |
| * type InputData = { name: string }; | |
| * type OutputData = { nameLength: number } | |
| * | |
| * // main.js | |
| * const worker = createTypedWorker<InputData, OutputData>(worker); | |
| * | |
| * // worker.js |
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 fetch from 'isomorphic-fetch' | |
| import { NextFunctionComponent, NextContext } from 'next' | |
| type InitialProps = PromiseResult<ReturnType<typeof getInitialProps>> | |
| type Props = InitialProps | |
| type Context = NextContext<{ subreddit: string }> | |
| const Posts: NextFunctionComponent<Props, InitialProps, Context> = ({ posts, subreddit }) => ( | |
| <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
| // Test Array | |
| const testArr = [1, 2, 3, 4, 5, 6]; | |
| // Utils | |
| const increment = val => val + 1; | |
| const greaterThan = min => val => val > min; | |
| const compose = (...fns) => (val) => fns.reduceRight((acc, fn) => fn(acc), val); | |
| const optCompose = (...fns) => fns.reduce((acc, fn) => x => acc(fn(x))); | |
| // Base Reducers |
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 accepts from 'attr-accept'; | |
| /** | |
| * @param {Number} maxSize Maximum File size (in bytes) | |
| * @param {Number} minSize Minimum File size (in bytes) | |
| * @param {File} file File Object | |
| */ | |
| export const fileMatchSize = (maxSize, minSize, file) => | |
| file.size <= maxSize && file.size >= minSize; |
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 {useRef, useEffect} from 'react'; | |
| /** | |
| * Hook for running effect on componentDidUpdate but not on componentDidMount | |
| */ | |
| const useComponentDidUpdate = (cb, dependencies) => { | |
| const mounted = useRef(false) | |
| useEffect(() => { | |
| if (mounted.current) { | |
| return cb() |
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
| /** | |
| * Absolute imports | |
| */ | |
| import React, { PureComponent } from 'react'; | |
| import PropTypes from 'prop-types'; | |
| import Dropzone from 'react-dropzone'; | |
| /** | |
| * Material UI | |
| */ | |
| import Button from '@material-ui/core/Button'; |
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
| /** | |
| * Absolute imports | |
| */ | |
| import React from 'react'; | |
| import PropTypes from 'prop-types'; | |
| import ReactSelect from 'react-select'; | |
| import CreatableSelect from 'react-select/lib/Creatable'; | |
| /** | |
| * Global Components |
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 { | |
| getTodos, | |
| createTodo, | |
| updateTodo, | |
| destroyTodo | |
| } from './lib/todoServices' | |
| import { createActions, handleActions, combineActions } from 'redux-actions' | |
| const initState = { | |
| todos: [], |
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 FormAutocompleteSelect from './FormAutocompleteSelect'; | |
| import { Field } from 'redux-form'; | |
| const countries = [ | |
| {value: 'AlbaniaCountry', label: 'Albania'}, | |
| {value:'AlgeriaCountry', label: 'Algeria'}, | |
| {value:'AndorraCountry', label: 'Andorra'}, | |
| {value:'AngolaCountry', label: 'Angola'} | |
| ]; |
NewerOlder