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 ReactDOM from 'react-dom' | |
| import { Provider } from 'react-redux' | |
| import { store } from 'Config/store' | |
| interface ReactComponentOptions { | |
| domID: string | |
| [key: string]: any | |
| } |
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 axios from 'axios'; | |
| /** | |
| * This hook makes use of the axios dependency. | |
| * @param path the endpoint in which you wish to make a request to | |
| * @param method the request method.. can be either 'get' or 'post'. | |
| * @param data an object containing the data/payload | |
| * @returns | |
| */ | |
| const useAxios = async ( |
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, { FC } from 'react'; | |
| interface ShapeInterface { | |
| type: 'rectangle' | 'circle' | 'triangle', | |
| backgroundColor?: string | |
| style?: { [key: string]: any } | |
| } | |
| const Shape: FC<ShapeInterface> = ({ type, backgroundColor = '#252525', style }): JSX.Element => { |
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 { useEffect, useState } from 'react'; | |
| /** | |
| * Adds a render delay variable that can be used on components | |
| * @param timeout | |
| * @param dependency | |
| * @example const visible = useRenderDelay(open, 2500); | |
| */ | |
| const useRenderDelay = (dependency: boolean, timeout = 1000): 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 React, { FC, lazy, Suspense, useState } from 'react'; | |
| // Code Spliting with dynamic imports | |
| const MenuContainer = lazy(() => | |
| import('./MenuContainer') | |
| .then(({ MenuContainer }) => ({ default: MenuContainer })), | |
| ); | |
| const Navigation: FC = (): JSX.Element => { |
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
| /** | |
| * Handle async looping | |
| * @param {any[]} array | |
| * @param {function} callback | |
| */ | |
| async asyncForEach(array, callback) { | |
| for (let index = 0; index < array.length; index++) { | |
| await callback(array[index], index, array); | |
| } | |
| } |
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 mongoose from 'mongoose'; | |
| interface DatabaseInterface { | |
| start(): void | |
| } | |
| class Database implements DatabaseInterface { | |
| private connection: string = ''; | |
| private username: string = 'YOUR_USERNAME'; |
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 { Request, Response, RequestHandler, NextFunction } from 'express'; | |
| export const asyncHandler = ( | |
| fn: (req: Request, res: Response, next: NextFunction) => void | |
| ): RequestHandler => (req, res, next) => { | |
| Promise.resolve(fn(req, res, next)).catch(next); | |
| }; |
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"; | |
| type KeyCode = { keyCode: number }; | |
| /** | |
| * Attaches keyup and keydown handlers to the window to detect | |
| * whether or not a particular key code has been pressed. | |
| * @param targetKey The key code | |
| * @returns {boolean} | |
| * @example const isPressed = useKeyPress(13); |
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
| /** | |
| * Extract specific files from HTMLWebpackPlugin | |
| * https://webpack.js.org/plugins/html-webpack-plugin/ | |
| */ | |
| <% function extractHash(pattern){ %> | |
| <% return Object.values(htmlWebpackPlugin.files.js).filter(function(val) { %> | |
| <% return val.match(pattern) %> | |
| <% }); %> | |
| <% } %> | |