Компоненты собственно бывают двух типов
Для начала возьмем компонент написанный на классе:
class SmartComponent extends Componennt {
static defaultProps = {
page: 1,
const future = executor => ({ | |
chain(fn) { | |
return future((resolve, reject) => | |
this.fork( | |
value => fn(value).fork(resolve), | |
error => reject(error), | |
) | |
) | |
}, | |
map(fn) { |
type LoaderProps<T> = { | |
fetching: boolean | |
data: T | |
} | |
const Loader: FC<LoaderProps> = ({ fetching, data, children }) => ( | |
if (fetching) { | |
return <div>Loading...</div> | |
} | |
return children(data) |
const createCache = () => { | |
const cacheMap = new Map() | |
return { | |
remember(key, setter) { | |
if (this.has(key)) { | |
return this.get(key) | |
} | |
const value = setter.call(null) | |
this.set(key, value) | |
return value |
withBemMod<P, T>(blockName: string, mod: NoStrictEntityMods, cb?: ModBody<P>): (WrappedComponent: EnhancedComponentType<{}, {}, T>) => (props: P) => JSX.Element; | |
type EnhancedComponentType<T = {}, S = any, V = any> = | |
& React.ComponentType<T> | |
& Nominal<V>; | |
type GetKey<T> = T extends EnhancedComponentType<any, any, infer V> ? V : never; | |
type GetProps<T> = T extends React.ComponentType<infer V> ? V : never; | |
export function composeM< |
SELECT CONCAT('ALTER TABLE `', t.`TABLE_SCHEMA`, '`.`', t.`TABLE_NAME`, '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;') as sqlcode | |
FROM `information_schema`.`TABLES` t | |
WHERE 1 | |
AND t.`TABLE_SCHEMA` = 'db_name' | |
ORDER BY 1 |
const easing = { | |
easeInCubic(t) { | |
return t ** 3 | |
}, | |
easeOutCubic(t) { | |
return (--t) * t ** 2 + 1 | |
}, | |
easeInOutCubic(t) { |