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, { | |
Children, | |
useCallback, | |
useRef, | |
useEffect, | |
useState, | |
} from 'react'; | |
import { | |
node, elementType, number, bool, string, func, | |
} from 'prop-types'; |
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, useEffect } from "react"; | |
import { useRouter } from "next/router"; | |
type IParam = string; | |
type IValue = string | string[] | number | number[] | null | undefined; | |
type IState = { [k: string]: IValue }; | |
type IQuery = IState; | |
type IRoute = string; | |
function isEmpty(value: IValue): boolean { |
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 styled from 'styled-components'; | |
import { | |
string, bool, oneOf, number, | |
} from 'prop-types'; | |
function filterObject (f, obj) { | |
return Object.fromEntries(Object.entries(obj).filter(f)); | |
} | |
function not (f) { |
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
/** | |
* Given an async function it will be executed until: | |
* - maxAttempts has been reached | |
* - it resolves | |
* - continueRef turned false | |
* | |
* Based off Trey Huffine's article: https://levelup.gitconnected.com/polling-in-javascript-ab2d6378705a | |
* Adapted to work on react components | |
* | |
* @param {Function} fn async function to execute. |
OlderNewer