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 UA = req.headers['user-agent']; | |
| const isMobile = Boolean(UA.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i)); |
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
| export const getTopY = (element: HTMLElement, downOffset: number): number => { | |
| return element.getBoundingClientRect().top + window.pageYOffset - downOffset; | |
| }; |
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, FunctionComponent } from 'react'; | |
| import { LoadingSpinner } from '@components/LoadingSpinner'; | |
| interface IProps { | |
| isLoading: boolean; | |
| } | |
| // eslint-disable-next-line @typescript-eslint/ban-types, react/display-name | |
| const WithLoadingSpinner = <P extends object>(Component: FunctionComponent<P>): FC<P & IProps> => ({ | |
| isLoading, |
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'; | |
| interface IProps { | |
| imagesToLoad: string[], | |
| } | |
| const useImagesAreLoaded = ({ imagesToLoad }: IProps): boolean => { | |
| const [loadedTilesCount, setLoadedTilesCount] = useState(0); | |
| useEffect((): void => { |
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, { | |
| useState, | |
| useLayoutEffect | |
| } from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| const BlinkyRender = () => { | |
| const [value, setValue] = useState(0); | |
| useLayoutEffect(() => { |
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
| fetchCsv() { | |
| var rawFile = new XMLHttpRequest(); | |
| rawFile.open("GET", require("path/to/local/file.txt"), false); | |
| rawFile.onreadystatechange = () => { | |
| if (rawFile.readyState === 4) { | |
| if (rawFile.status === 200 || rawFile.status === 0) { | |
| var allText = rawFile.responseText; | |
| Papa.parse(allText, { | |
| complete: this.setData, // in this case, set the text as react state |
NewerOlder