- Написать про то, что такое API компонента и на самом деле модификаторы являются частью компонента при проектировании
- Написать про createClassNameModifier/withBemMod/dedup cn — что это на самом деле все не нужно
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 { useState } from 'react' | |
import { useUniqId } from '../../libs/useUniqId' | |
export function useSelectState(props: any) { | |
const { children } = props | |
const [isOpened, setOpened] = useState(false) | |
const [selected, setSelected] = useState<{ option: any; value: any }>({} as any) | |
const [focusedIndex, setFocusedIndex] = useState(-1) | |
const [selectedIndex, setSelectedIndex] = useState(-1) |
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 { useState, useEffect } from "react"; | |
export function useIsClient() { | |
const [isClient, setClient] = useState(false); | |
useEffect(() => { | |
setClient(true); | |
}, []); | |
return isClient; |
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 locales = [ | |
{ label: 'Auto', value: '' }, | |
// Tier 1 | |
{ label: 'French (France)', value: 'fr-FR' }, | |
{ label: 'French (Canada)', value: 'fr-CA' }, | |
{ label: 'German (Germany)', value: 'de-DE' }, | |
{ label: 'English (Great Britain)', value: 'en-GB' }, | |
{ label: 'English (United States)', value: 'en-US' }, | |
{ label: 'Japanese (Japan)', value: 'ja-JP' }, | |
// // Tier 2 |
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
/* eslint-disable no-console */ | |
import { useRef, useEffect } from 'react'; | |
export function useWhyDidYouUpdate(name: string, props: any) { | |
// Get a mutable ref object where we can store props ... | |
// ... for comparison next time this hook runs. | |
const previousProps = useRef<any>(); | |
useEffect(() => { | |
if (previousProps.current) { |
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 default function deprecated(props, instead, component) { | |
if (typeof window !== 'undefined' && window.console && window.console.error) { | |
window.console.error( | |
`Warning: ${props} is deprecated at [ ${component} ], ` + | |
`use [ ${instead} ] instead of it.` | |
); | |
} | |
} |
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 useCopyToClipboard = (text) => { | |
const copyToClipboard = (str) => { | |
const el = document.createElement('textarea'); | |
el.value = str; | |
el.setAttribute('readonly', ''); | |
el.style.position = 'absolute'; | |
el.style.left = '-9999px'; | |
document.body.appendChild(el); | |
const selected = | |
document.getSelection().rangeCount > 0 |
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 { | |
EffectCallback, | |
DependencyList, | |
useLayoutEffect, | |
useState, | |
useEffect, | |
useMemo, | |
} from 'react' | |
// lib/canUseDOM |