This file contains 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
{"version":1,"resource":"file:///home/erik/Projects/ecommerce-front/src/hooks/useInView/index.tsx","entries":[{"id":"afXk.tsx","source":"Fix all fixable ESLint issues","timestamp":1658516663546},{"id":"yblD.tsx","source":"Add import from \"@/helpers/ssrHelper\"","timestamp":1658516710521},{"id":"NxMr.tsx","timestamp":1658516715321},{"id":"D7Nn.tsx","source":"Fix all fixable ESLint issues","timestamp":1659460328205}]} |
This file contains 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 { throttle } from './throttle'; | |
beforeEach(() => { | |
jest.useFakeTimers('modern'); | |
}); | |
describe('helpers/throttle', () => { | |
it('when delayed', () => { | |
const fn = jest.fn(); | |
const throttleFn = throttle(fn, 3000); |
This file contains 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 { ReactNode } from 'react'; | |
export type ComponentWithChildren = (props: { | |
children: ReactNode; | |
}) => JSX.Element; | |
export const composer = (...providers: ComponentWithChildren[]) => { | |
const ComposedComponents: ComponentWithChildren = ({ children }) => { | |
return ( | |
<> |
This file contains 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 mostFrequentDays = year => { | |
let dayName = d => d.toLocaleString('en',{ weekday:'long' }); | |
let firstDay = new Date(year, 0, 1); | |
let day = dayName(firstDay); | |
let lastDay = dayName(new Date(year, 11, 31)); | |
let daysResult = day == lastDay? [day] : [day, lastDay]; | |
return firstDay.getDay() ? daysResult : daysResult.reverse(); | |
}; |
This file contains 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 { render } from '@testing-library/react'; | |
import { <%= className %> } from './<%= fileName %>'; | |
describe('<<%= className %>/>', () => { | |
it('should render successfully', () => { | |
const { baseElement } = render(<<%= className %> />); | |
expect(baseElement).toBeTruthy(); | |
}); |
This file contains 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 pick = <T, K extends keyof T>(obj: T, properties: Array<K>) => | |
Object.fromEntries(properties.map((key) => [key, obj[key]])) as Pick<T, K>; | |
interface ExampleObject { | |
id: number; | |
name: string; | |
birthDate: string; | |
idol: string; | |
} |
This file contains 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, { useEffect, useRef } from "react"; | |
export type useRunOnceProps = { | |
fn: () => any; | |
sessionKey?: string; | |
}; | |
const useRunOnce: React.FC<useRunOnceProps> = ({ fn, sessionKey }) => { | |
const triggered = useRef<boolean>(false); |
This file contains 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 { | |
useCallback, useEffect, useRef, useState, | |
} from 'react' | |
const DEFAULT_THROTTLE_MS = 3000 | |
const getRemainingTime = (lastTriggeredTime: number, throttleMs: number) => { | |
const elapsedTime = Date.now() - lastTriggeredTime | |
const remainingTime = throttleMs - elapsedTime |
This file contains 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 { useCallback, useEffect, useRef } from 'react' | |
const DEFAULT_THROTTLE_MS = 800 | |
const getRemainingTime = (lastTriggeredTime: number, throttleMs: number) => { | |
const elapsedTime = Date.now() - lastTriggeredTime | |
const remainingTime = throttleMs - elapsedTime | |
return (remainingTime < 0) ? 0 : remainingTime | |
} |
This file contains 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 namedComponent = async <T, N extends keyof T>( | |
modPromise: Promise<T>, | |
exportName: N, | |
) => { | |
const mod = await modPromise; | |
return mod[exportName]; | |
}; |
OlderNewer