{"id":346625,"date":"2023-03-12T21:01:19","date_gmt":"2023-03-12T21:01:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=346625"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2023-03-12T21:01:19","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=346625","title":{"rendered":"<span>React \u0438 Typescript: \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043a\u043d\u043e\u043f\u043a\u0438<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>React \u0438 Typescript \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043c\u043e\u0449\u043d\u044b\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043a\u043d\u043e\u043f\u043a\u0438, \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c React \u0438 Typescript.<\/p>\n<h3>\u0427\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435?<\/h3>\n<p>\u041a\u043d\u043e\u043f\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043c\u043e\u0436\u0435\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u043f\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438\u043b\u0438 \u0438\u043c\u044f \u0442\u0435\u0433\u0430 \u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u0432\u0441\u0435 \u0432 \u0435\u0434\u0438\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435<br \/>\u041f\u0440\u0438\u043c\u0435\u0440 3 \u043a\u043d\u043e\u043f\u043e\u043a:<\/p>\n<pre><code>\/\/\u0421\u0430\u043c\u0430\u044f \u043e\u0431\u044b\u0447\u043d\u0430\u044f \u043a\u043d\u043e\u043f\u043a\u0430 &lt;Button onClick={showAlert}>Hello! It's button!&lt;\/Button>  \/\/\u0421\u0441\u044b\u043b\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0449\u0430\u044f \u043a\u0430\u043a \u043a\u043d\u043e\u043f\u043a\u0430 &lt;Button   component={'a'}   target=\"_blank\"   href=\"https:\/\/www.google.ru\/\" >   It's Google link! &lt;\/Button>  \/\/\u0421\u0441\u044b\u043b\u043a\u0430 \u0438\u0437 react-router-dom \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u043d\u0430\u0448\u0430 \u043a\u043d\u043e\u043f\u043a\u0430 \/\/import { Link } from 'react-router-dom' &lt;Button component={Link} to=\"\/link-route\">   It's router link! &lt;\/Button><\/code><\/pre>\n<p>\u0412\u0441\u0435 \u044d\u0442\u0438 \u0442\u0440\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <strong>\u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/strong>, \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f <code>disabled<\/code> \u0438 <code>loading<\/code> \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0432\u043e \u0432\u0441\u0435\u0445 3 \u0441\u043b\u0443\u0447\u0430\u044f\u0445<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 typescript \u043d\u0430\u043c \u0432\u043e \u0432\u0441\u0435\u0445 \u0442\u0440\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441 \u043f\u0440\u043e\u043f\u0430\u043c\u0438, \u0442.e. \u043e\u043d \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u043f\u044b \u0438 \u0438\u0445 \u0442\u0438\u043f\u044b<\/p>\n<h3>\u0427\u0442\u043e \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430<\/h3>\n<ol>\n<li>\n<p>React<\/p>\n<\/li>\n<li>\n<p>Typescript<\/p>\n<\/li>\n<li>\n<p>SCSS &#8212; \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0438\u043b\u0435\u0439<\/p>\n<\/li>\n<li>\n<p>clsx &#8212; \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0434\u043b\u044f \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a className<\/p>\n<\/li>\n<\/ol>\n<h3>\u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/h3>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 &#171;BaseButton&#187;, \u0430 \u0432 \u043d\u0435\u0439 \u0444\u0430\u0439\u043b <code>BaseButton.tsx<\/code>. <code>BaseButton<\/code> \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 &#171;Button&#187;, \u0430 \u0432 \u043d\u0435\u0439 \u0444\u0430\u0439\u043b <code>Button.tsx<\/code>. <code>Button<\/code> \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0442\u0438\u043b\u0438 \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0435 &#171;Button&#187; scss \u0444\u0430\u0439\u043b <code>Button.module.scss<\/code>, \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u043c\u043e\u0434\u0443\u043b\u044c, \u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0441\u0442\u0438\u043b\u0435\u0439.<\/p>\n<\/li>\n<\/ol>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f BaseButton<\/h3>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0444\u0430\u0439\u043b &#171;BaseButton.tsx&#187; \u043a\u043e\u0434 \u043d\u0438\u0436\u0435 \u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0435\u0433\u043e \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c:<\/p>\n<pre><code>import {   Attributes,   createElement,   CSSProperties,   ComponentType,   ComponentPropsWithRef, } from 'react'  export type BaseButtonComponent =   | keyof JSX.IntrinsicElements   | ComponentType&lt;any>  type BaseProps&lt;C extends BaseButtonComponent = 'button'> = {   component?: C   className?: string   style?: CSSProperties } &amp; Attributes  export type BaseButtonProps&lt;C extends BaseButtonComponent = 'button'> =   C extends keyof JSX.IntrinsicElements     ? Omit&lt;ComponentPropsWithRef&lt;C>, keyof BaseProps&lt;C>> &amp; BaseProps&lt;C>     : C extends ComponentType&lt;infer P>     ? P extends ComponentPropsWithRef&lt;any>       ? Omit&lt;P, keyof BaseProps&lt;C>> &amp; BaseProps&lt;C>       : never     : never  export default function BaseButton&lt;C extends BaseButtonComponent = 'button'>({   component = 'button',   children,   ...props }: BaseButtonProps&lt;C>) {   return createElement(component, props, children) }<\/code><\/pre>\n<h4>\u0422\u0438\u043f\u044b BaseButton<\/h4>\n<p>\u0422\u0438\u043f <code>BaseProps<\/code> &#8212; \u043e\u043d \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u043f\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430: <code>component<\/code>, <code>className<\/code>, <code>style<\/code><br \/>\u041f\u0440\u043e\u043f <code>component<\/code> \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430 \u0442\u043e, \u043a\u0430\u043a\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c, \u043e\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u0442\u0438\u043f\u0430 <code>BaseButtonComponent<\/code> \u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0443\u0434\u0435\u0442 <code>button<\/code> \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c <code>&lt;C extends BaseButtonComponent = 'button'><\/code> <\/p>\n<p>\u0422\u0438\u043f <code>BaseButtonComponent<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u0430\u043a\u0438\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442:<\/p>\n<ul>\n<li>\n<p><code>ComponentType<\/code> (\u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u044c \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u0430\u043a <code>type ComponentType&lt;P = {}> = ComponentClass&lt;P> | FunctionComponent&lt;P><\/code>) \u0442.e. \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u043f\u0430 <code>component<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/p>\n<\/li>\n<li>\n<p><code>keyof JSX.IntrinsicElements<\/code> (\u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0433\u043b\u044f\u043d\u0435\u043c \u0432 \u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code>interface IntrinsicElements {   \/\/ HTML   a: React.DetailedHTMLProps&lt;React.AnchorHTMLAttributes&lt;HTMLAnchorElement>, HTMLAnchorElement>;   abbr: React.DetailedHTMLProps&lt;React.HTMLAttributes&lt;HTMLElement>, HTMLElement>;   address: React.DetailedHTMLProps&lt;React.HTMLAttributes&lt;HTMLElement>, HTMLElement>;   area: React.DetailedHTMLProps&lt;React.AreaHTMLAttributes&lt;HTMLAreaElement>, HTMLAreaElement>;   article: React.DetailedHTMLProps&lt;React.HTMLAttributes&lt;HTMLElement>, HTMLElement>;   ...   \/\/\u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0435 \u0442\u0435\u0433\u0438 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443 }<\/code><\/pre>\n<p>\u0442.e <code>IntrinsicElements<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0445 \u0442\u044d\u0433\u043e\u0432 \u0434\u043b\u044f \u0440\u0435\u0430\u043a\u0442\u0430.<br \/>C \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>keyof<\/code> \u043c\u044b \u043a\u0430\u043a \u0440\u0430\u0437 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0441\u0435 \u043a\u043b\u044e\u0447\u0438 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0445 \u0442\u044d\u0433\u043e\u0432, \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043b\u044f \u0442\u0430\u0439\u043f\u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043a\u0430\u043a <code>'a' | 'abbr' | 'address' | 'area' | &lt;\u0438 \u0432\u0441\u0435 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443><\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u0422.e. <code>BaseButtonComponent<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0438\u0431\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u043c, \u043b\u0438\u0431\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c, \u043b\u0438\u0431\u043e \u043b\u044e\u0431\u044b\u043c \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c \u0442\u044d\u0433\u043e\u043c \u0434\u043b\u044f \u0440\u0435\u0430\u043a\u0442\u0430<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0442\u0438\u043f <code>BaseButtonProps<\/code>, \u0435\u0441\u043b\u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0433\u043e \u0442\u0440\u0435\u043c\u044f \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u0442\u043e \u044d\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0442\u0435\u0440\u043d\u0430\u0440\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0433\u043e \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c<\/p>\n<ol>\n<li>\n<p>\u041e\u043d \u0443 \u043d\u0430\u0441 \u0442\u043e\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u043c: <code>&lt;C extends BaseButtonComponent = 'button'><\/code><\/p>\n<\/li>\n<li>\n<p> \u0415\u0441\u043b\u0438 \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 &#171;\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0445 \u0442\u044d\u0433\u043e\u0432&#187; \u0442\u043e \u043c\u044b \u0431\u0435\u0440\u0435\u043c \u043f\u0440\u043e\u043f\u044b \u044d\u0442\u043e\u0433\u043e \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0433\u043e \u0442\u044d\u0433\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>ComponentPropsWithRef<\/code> \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0438\u0437 \u043d\u0435\u0433\u043e \u043f\u0440\u043e\u043f\u044b \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0436\u0435 \u043a\u043b\u044e\u0447\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0432 BaseProps (\u043a\u0430\u043a \u043c\u044b \u043f\u043e\u043c\u043d\u0438\u043c \u044d\u0442\u043e <code>component<\/code>, <code>classNames<\/code>, <code>styles<\/code>) \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448\u0438 \u043f\u0440\u043e\u043f\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0432 <code>BaseProps<\/code> . E\u0441\u043b\u0438 \u0432\u044b\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443, \u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043f\u0440\u043e\u043f\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0441 \u043a\u043b\u044e\u0447\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0432 <code>BaseProps<\/code> \u043d\u0430 \u043d\u0430\u0448\u0438 \u043f\u0440\u043e\u043f\u044b <code>BaseProps<\/code><\/p>\n<pre><code>C extends keyof JSX.IntrinsicElements     ? Omit&lt;ComponentPropsWithRef&lt;C>, keyof BaseProps&lt;C>> &amp; BaseProps&lt;C> : &lt;...><\/code><\/pre>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0442\u043e \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>infer<\/code> \u0435\u0433\u043e \u043f\u0440\u043e\u043f\u044b \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u0445 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>P<\/code>, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0442\u0443 \u0436\u0435 \u0441\u0430\u043c\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u044f \u0441 \u044d\u0442\u0438\u043c\u0438 \u043f\u0440\u043e\u043f\u0430\u043c\u0438<\/p>\n<pre><code>C extends ComponentType&lt;infer P>     ? P extends ComponentPropsWithRef&lt;any>       ? Omit&lt;P, keyof BaseProps&lt;C>> &amp; BaseProps&lt;C><\/code><\/pre>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c \u0442\u043e \u043c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c <code>never<\/code> \u0442.e. \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u043f\u043e\u0432<\/p>\n<\/li>\n<\/ol>\n<h4>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 BaseButton<\/h4>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>BaseButton<\/code><\/p>\n<pre><code>export default function BaseButton&lt;C extends BaseButtonComponent = 'button'>({   component = 'button',   children,   ...props }: BaseButtonProps&lt;C>) {   return createElement(component, props, children) }<\/code><\/pre>\n<ol>\n<li>\n<p>\u0417\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0442\u043e\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u043f\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0440\u0435\u0441\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u0434\u043b\u044f, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e component \u0438 children<\/p>\n<\/li>\n<li>\n<p>\u0421\u0430\u043c \u0436\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0435\u0430\u043a\u0442\u0430 createElement, \u043f\u0435\u0440\u0432\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u0432\u0442\u043e\u0440\u044b\u043c \u0435\u0433\u043e \u043f\u0440\u043e\u043f\u044b, \u0442\u0440\u0435\u0442\u0438\u043c \u0447\u0438\u043b\u0434\u0440\u0435\u043d\u044b<\/p>\n<p>\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a: <code>createElement('div', { className: &lt;\u043a\u0430\u043a\u043e\u0439 \u0442\u043e \u043a\u043b\u0430\u0441\u0441> }, '\u0442\u0435\u043a\u0441\u0442')<\/code><\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c, \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u043a\u0443\u0441 \u0438 \u0446\u0432\u0435\u0442 \ud83d\ude42<\/p>\n<\/li>\n<\/ol>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Button<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0444\u0430\u0439\u043b <code>Button.tsx<\/code> \u043a\u043e\u0434 \u0438 \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442:<\/p>\n<pre><code>import clsx from 'clsx'  import BaseButton, {   BaseButtonProps,   BaseButtonComponent, } from '..\/BaseButton\/BaseButton'  import styles from '.\/Button.module.scss'  export type ButtonProps&lt;C extends BaseButtonComponent = 'button'> =   BaseButtonProps&lt;C> &amp; {     loading?: boolean     disabled?: boolean   }  export function Button&lt;C extends BaseButtonComponent = 'button'>({   className,   loading,   disabled,   ...props }: ButtonProps&lt;C>) {   return (     &lt;BaseButton&lt;C>       className={clsx(         styles.button,         {           [styles.loading]: loading,           [styles.disabled]: disabled,         },         className,       )}       {...(props as BaseButtonProps&lt;C>)}     \/>   ) } <\/code><\/pre>\n<ol>\n<li>\n<p>\u041e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <code>BaseButton<\/code><\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u043f\u044b <code>disabled<\/code> \u0438 <code>loading<\/code>, \u0442.e. \u0442\u0438\u043f <code>ButtonProps<\/code> \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u0442\u0438\u043f <code>BaseButtonProps<\/code><\/p>\n<\/li>\n<li>\n<p>\u0422\u0438\u043f <code>BaseButtonProps<\/code> \u0442\u0430\u043a \u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u043c, \u0447\u0442\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0442\u0438\u043f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043e\u0442 <code>BaseButtonComponent<\/code><\/p>\n<\/li>\n<li>\n<p>\u0422.\u043a. <code>BaseButton<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u043c, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <code>Button<\/code> \u0442\u043e\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u043c \u0442\u043e \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u0442\u0438\u043f BaseButton \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u043c \u043e\u0442 <code>Button<\/code> \u0442\u0430\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c: <code>&lt;BaseButton&lt;C><\/code> \u0438\u043d\u0430\u0447\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 ts \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u043e\u0442 \u043d\u0435\u0433\u043e \u0445\u043e\u0442\u0438\u043c<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f <code>disabled<\/code> \u0438\u043b\u0438 <code>loading \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c<\/code> \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0442\u0438\u043b\u0438 \u043d\u0430\u0448\u0435\u0439 \u043a\u043d\u043e\u043f\u043a\u0435<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043b\u0438\u0448\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u0438\u043b\u0435\u0439, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0438\u0445 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u0442\u0438\u043b\u0438 \u043a\u043d\u043e\u043f\u043a\u0438 \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>.button {   outline: none;   border: none;   position: relative;   display: flex;   align-items: center;   justify-content: center;   min-height: 60px;   padding: 0 20px;   font-size: 16px;   font-weight: 500;   text-align: center;   text-decoration: none;   color: #fff;   background-color: #2196f3;   border-radius: 10px;   cursor: pointer;   transition: background-color 0.2s ease-in-out;    &amp;:hover {     background-color: #1976d2;     color: #fff;   }    &amp;:focus {     outline: none;     box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);   }    &amp;:active {     background-color: #0d47a1;     color: #fff;   }    &amp;.disabled, &amp;.loading {     background-color: grey;     pointer-events: none;      &amp;:hover {       background-color: grey;     }      &amp;:focus {       box-shadow:none;     }   }    &amp;.loading {     &amp;:after {       content: \"\";       position: absolute;       top: 6px;       left: 6px;       width: 6px;       height: 6px;       border-radius: 50%;       border: 2px solid #fff;       border-top-color: transparent;       animation: loading 0.8s linear infinite;     }   } }  @keyframes loading {   to { transform: rotate(360deg); } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0439 \u043a\u043d\u043e\u043f\u043a\u0438<\/h3>\n<ul>\n<li>\n<p>\u041e\u0431\u044b\u0447\u043d\u0430\u044f \u043a\u043d\u043e\u043f\u043a\u0430<\/p>\n<pre><code>&lt;Button onClick={showAlert}>Hello! It's button!&lt;\/Button><\/code><\/pre>\n<\/li>\n<li>\n<p>\u0421\u0441\u044b\u043b\u043a\u0430<\/p>\n<pre><code>&lt;Button   component={'a'}   target=\"_blank\"   href=\"https:\/\/www.google.ru\/\" >   It's Google link! &lt;\/Button><\/code><\/pre>\n<\/li>\n<li>\n<p>\u0420\u043e\u0443\u0442\u0435\u0440 Link<\/p>\n<pre><code>&lt;Button component={Link} to=\"\/link-route\">   It's router link! &lt;\/Button><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<h3>C\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 codesandbox \u0438 github<\/h3>\n<p><a href=\"https:\/\/codesandbox.io\/s\/eager-parm-f76hhy?file=\/src\/App.tsx\" rel=\"noopener noreferrer nofollow\">codesandbox<\/a> &#8212; \u043a\u043b\u0438\u043a\u0430\u0439\u0442\u0435 \u043f\u043e \u043a\u043d\u043e\u043f\u043a\u0430\u043c, \u044e\u0437\u0430\u0439\u0442\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043d\u043e\u043f\u043e\u043a<br \/><a href=\"https:\/\/github.com\/finesunes\/dynamic-button\" rel=\"noopener noreferrer nofollow\">github<\/a><\/p>\n<h3>\u041f\u043e\u0441\u043b\u0435\u0441\u043b\u043e\u0432\u0438\u0435<\/h3>\n<p>\u0418\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0438\u043f\u0430 <code>ButtonBaseProps<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443 \u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f<\/p>\n<pre><code>type DistributiveOmit&lt;T, K extends keyof any> = T extends any   ? Omit&lt;T, K>   : never<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u044f \u0432\u0430\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0438\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0447\u0442\u043e \u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c &#8212; \u0432\u044d\u043b\u043a\u0430\u043c \u0442\u0443 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0441<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/721862\/\"> https:\/\/habr.com\/ru\/post\/721862\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>React \u0438 Typescript \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043c\u043e\u0449\u043d\u044b\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043a\u043d\u043e\u043f\u043a\u0438, \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c React \u0438 Typescript.<\/p>\n<h3>\u0427\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435?<\/h3>\n<p>\u041a\u043d\u043e\u043f\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043c\u043e\u0436\u0435\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u043f\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438\u043b\u0438 \u0438\u043c\u044f \u0442\u0435\u0433\u0430 \u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u0432\u0441\u0435 \u0432 \u0435\u0434\u0438\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435<br \/>\u041f\u0440\u0438\u043c\u0435\u0440 3 \u043a\u043d\u043e\u043f\u043e\u043a:<\/p>\n<pre><code>\/\/\u0421\u0430\u043c\u0430\u044f \u043e\u0431\u044b\u0447\u043d\u0430\u044f \u043a\u043d\u043e\u043f\u043a\u0430 &lt;Button onClick={showAlert}>Hello! It's button!&lt;\/Button>  \/\/\u0421\u0441\u044b\u043b\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0449\u0430\u044f \u043a\u0430\u043a \u043a\u043d\u043e\u043f\u043a\u0430 &lt;Button   component={'a'}   target=\"_blank\"   href=\"https:\/\/www.google.ru\/\" >   It's Google link! &lt;\/Button>  \/\/\u0421\u0441\u044b\u043b\u043a\u0430 \u0438\u0437 react-router-dom \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u043d\u0430\u0448\u0430 \u043a\u043d\u043e\u043f\u043a\u0430 \/\/import { Link } from 'react-router-dom' &lt;Button component={Link} to=\"\/link-route\">   It's router link! &lt;\/Button><\/code><\/pre>\n<p>\u0412\u0441\u0435 \u044d\u0442\u0438 \u0442\u0440\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <strong>\u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/strong>, \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f <code>disabled<\/code> \u0438 <code>loading<\/code> \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0432\u043e \u0432\u0441\u0435\u0445 3 \u0441\u043b\u0443\u0447\u0430\u044f\u0445<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 typescript \u043d\u0430\u043c \u0432\u043e \u0432\u0441\u0435\u0445 \u0442\u0440\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441 \u043f\u0440\u043e\u043f\u0430\u043c\u0438, \u0442.e. \u043e\u043d \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u043f\u044b \u0438 \u0438\u0445 \u0442\u0438\u043f\u044b<\/p>\n<h3>\u0427\u0442\u043e \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430<\/h3>\n<ol>\n<li>\n<p>React<\/p>\n<\/li>\n<li>\n<p>Typescript<\/p>\n<\/li>\n<li>\n<p>SCSS &#8212; \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0438\u043b\u0435\u0439<\/p>\n<\/li>\n<li>\n<p>clsx &#8212; \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0434\u043b\u044f \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a className<\/p>\n<\/li>\n<\/ol>\n<h3>\u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/h3>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 &#171;BaseButton&#187;, \u0430 \u0432 \u043d\u0435\u0439 \u0444\u0430\u0439\u043b <code>BaseButton.tsx<\/code>. <code>BaseButton<\/code> \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 &#171;Button&#187;, \u0430 \u0432 \u043d\u0435\u0439 \u0444\u0430\u0439\u043b <code>Button.tsx<\/code>. <code>Button<\/code> \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0442\u0438\u043b\u0438 \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0435 &#171;Button&#187; scss \u0444\u0430\u0439\u043b <code>Button.module.scss<\/code>, \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u043c\u043e\u0434\u0443\u043b\u044c, \u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0441\u0442\u0438\u043b\u0435\u0439.<\/p>\n<\/li>\n<\/ol>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f BaseButton<\/h3>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0444\u0430\u0439\u043b &#171;BaseButton.tsx&#187; \u043a\u043e\u0434 \u043d\u0438\u0436\u0435 \u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0435\u0433\u043e \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c:<\/p>\n<pre><code>import {   Attributes,   createElement,   CSSProperties,   ComponentType,   ComponentPropsWithRef, } from 'react'  export type BaseButtonComponent =   | keyof JSX.IntrinsicElements   | ComponentType&lt;any>  type BaseProps&lt;C extends BaseButtonComponent = 'button'> = {   component?: C   className?: string   style?: CSSProperties } &amp; Attributes  export type BaseButtonProps&lt;C extends BaseButtonComponent = 'button'> =   C extends keyof JSX.IntrinsicElements     ? Omit&lt;ComponentPropsWithRef&lt;C>, keyof BaseProps&lt;C>> &amp; BaseProps&lt;C>     : C extends ComponentType&lt;infer P>     ? P extends ComponentPropsWithRef&lt;any>       ? Omit&lt;P, keyof BaseProps&lt;C>> &amp; BaseProps&lt;C>       : never     : never  export default function BaseButton&lt;C extends BaseButtonComponent = 'button'>({   component = 'button',   children,   ...props }: BaseButtonProps&lt;C>) {   return createElement(component, props, children) }<\/code><\/pre>\n<h4>\u0422\u0438\u043f\u044b BaseButton<\/h4>\n<p>\u0422\u0438\u043f <code>BaseProps<\/code> &#8212; \u043e\u043d \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u043f\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430: <code>component<\/code>, <code>className<\/code>, <code>style<\/code><br \/>\u041f\u0440\u043e\u043f <code>component<\/code> \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430 \u0442\u043e, \u043a\u0430\u043a\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c, \u043e\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u0442\u0438\u043f\u0430 <code>BaseButtonComponent<\/code> \u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0443\u0434\u0435\u0442 <code>button<\/code> \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c <code>&lt;C extends BaseButtonComponent = 'button'><\/code> <\/p>\n<p>\u0422\u0438\u043f <code>BaseButtonComponent<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u0430\u043a\u0438\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442:<\/p>\n<ul>\n<li>\n<p><code>ComponentType<\/code> (\u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u044c \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u0430\u043a <code>type ComponentType&lt;P = {}> = ComponentClass&lt;P> | FunctionComponent&lt;P><\/code>) \u0442.e. \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u043f\u0430 <code>component<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/p>\n<\/li>\n<li>\n<p><code>keyof JSX.IntrinsicElements<\/code> (\u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0433\u043b\u044f\u043d\u0435\u043c \u0432 \u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code>interface IntrinsicElements {   \/\/ HTML   a: React.DetailedHTMLProps&lt;React.AnchorHTMLAttributes&lt;HTMLAnchorElement>, HTMLAnchorElement>;   abbr: React.DetailedHTMLProps&lt;React.HTMLAttributes&lt;HTMLElement>, HTMLElement>;   address: React.DetailedHTMLProps&lt;React.HTMLAttributes&lt;HTMLElement>, HTMLElement>;   area: React.DetailedHTMLProps&lt;React.AreaHTMLAttributes&lt;HTMLAreaElement>, HTMLAreaElement>;   article: React.DetailedHTMLProps&lt;React.HTMLAttributes&lt;HTMLElement>, HTMLElement>;   ...   \/\/\u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0435 \u0442\u0435\u0433\u0438 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443 }<\/code><\/pre>\n<p>\u0442.e <code>IntrinsicElements<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0445 \u0442\u044d\u0433\u043e\u0432 \u0434\u043b\u044f \u0440\u0435\u0430\u043a\u0442\u0430.<br \/>C \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>keyof<\/code> \u043c\u044b \u043a\u0430\u043a \u0440\u0430\u0437 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0441\u0435 \u043a\u043b\u044e\u0447\u0438 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0445 \u0442\u044d\u0433\u043e\u0432, \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043b\u044f \u0442\u0430\u0439\u043f\u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043a\u0430\u043a <code>'a' | 'abbr' | 'address' | 'area' | &lt;\u0438 \u0432\u0441\u0435 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443><\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u0422.e. <code>BaseButtonComponent<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0438\u0431\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u043c, \u043b\u0438\u0431\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c, \u043b\u0438\u0431\u043e \u043b\u044e\u0431\u044b\u043c \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c \u0442\u044d\u0433\u043e\u043c \u0434\u043b\u044f \u0440\u0435\u0430\u043a\u0442\u0430<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0442\u0438\u043f <code>BaseButtonProps<\/code>, \u0435\u0441\u043b\u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0433\u043e \u0442\u0440\u0435\u043c\u044f \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u0442\u043e \u044d\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0442\u0435\u0440\u043d\u0430\u0440\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0433\u043e \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c<\/p>\n<ol>\n<li>\n<p>\u041e\u043d \u0443 \u043d\u0430\u0441 \u0442\u043e\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u043c: <code>&lt;C extends BaseButtonComponent = 'button'><\/code><\/p>\n<\/li>\n<li>\n<p> \u0415\u0441\u043b\u0438 \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 &#171;\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0445 \u0442\u044d\u0433\u043e\u0432&#187; \u0442\u043e \u043c\u044b \u0431\u0435\u0440\u0435\u043c \u043f\u0440\u043e\u043f\u044b \u044d\u0442\u043e\u0433\u043e \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0433\u043e \u0442\u044d\u0433\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>ComponentPropsWithRef<\/code> \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0438\u0437 \u043d\u0435\u0433\u043e \u043f\u0440\u043e\u043f\u044b \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0436\u0435 \u043a\u043b\u044e\u0447\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0432 BaseProps (\u043a\u0430\u043a \u043c\u044b \u043f\u043e\u043c\u043d\u0438\u043c \u044d\u0442\u043e <code>component<\/code>, <code>classNames<\/code>, <code>styles<\/code>) \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448\u0438 \u043f\u0440\u043e\u043f\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0432 <code>BaseProps<\/code> . E\u0441\u043b\u0438 \u0432\u044b\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443, \u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043f\u0440\u043e\u043f\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0441 \u043a\u043b\u044e\u0447\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0432 <code>BaseProps<\/code> \u043d\u0430 \u043d\u0430\u0448\u0438 \u043f\u0440\u043e\u043f\u044b <code>BaseProps<\/code><\/p>\n<pre><code>C extends keyof JSX.IntrinsicElements     ? Omit&lt;ComponentPropsWithRef&lt;C>, keyof BaseProps&lt;C>> &amp; BaseProps&lt;C> : &lt;...><\/code><\/pre>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0442\u043e \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>infer<\/code> \u0435\u0433\u043e \u043f\u0440\u043e\u043f\u044b \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u0445 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>P<\/code>, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0442\u0443 \u0436\u0435 \u0441\u0430\u043c\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u044f \u0441 \u044d\u0442\u0438\u043c\u0438 \u043f\u0440\u043e\u043f\u0430\u043c\u0438<\/p>\n<pre><code>C extends ComponentType&lt;infer P>     ? P extends ComponentPropsWithRef&lt;any>       ? Omit&lt;P, keyof BaseProps&lt;C>> &amp; BaseProps&lt;C><\/code><\/pre>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c \u0442\u043e \u043c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c <code>never<\/code> \u0442.e. \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u043f\u043e\u0432<\/p>\n<\/li>\n<\/ol>\n<h4>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 BaseButton<\/h4>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>BaseButton<\/code><\/p>\n<pre><code>export default function BaseButton&lt;C extends BaseButtonComponent = 'button'>({   component = 'button',   children,   ...props }: BaseButtonProps&lt;C>) {   return createElement(component, props, children) }<\/code><\/pre>\n<ol>\n<li>\n<p>\u0417\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0442\u043e\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u043f\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0440\u0435\u0441\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u0434\u043b\u044f, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e component \u0438 children<\/p>\n<\/li>\n<li>\n<p>\u0421\u0430\u043c \u0436\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0435\u0430\u043a\u0442\u0430 createElement, \u043f\u0435\u0440\u0432\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u0432\u0442\u043e\u0440\u044b\u043c \u0435\u0433\u043e \u043f\u0440\u043e\u043f\u044b, \u0442\u0440\u0435\u0442\u0438\u043c \u0447\u0438\u043b\u0434\u0440\u0435\u043d\u044b<\/p>\n<p>\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a: <code>createElement('div', { className: &lt;\u043a\u0430\u043a\u043e\u0439 \u0442\u043e \u043a\u043b\u0430\u0441\u0441> }, '\u0442\u0435\u043a\u0441\u0442')<\/code><\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c, \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u043a\u0443\u0441 \u0438 \u0446\u0432\u0435\u0442 \ud83d\ude42<\/p>\n<\/li>\n<\/ol>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Button<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0444\u0430\u0439\u043b <code>Button.tsx<\/code> \u043a\u043e\u0434 \u0438 \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442:<\/p>\n<pre><code>import clsx from 'clsx'  import BaseButton, {   BaseButtonProps,   BaseButtonComponent, } from '..\/BaseButton\/BaseButton'  import styles from '.\/Button.module.scss'  export type ButtonProps&lt;C extends BaseButtonComponent = 'button'> =   BaseButtonProps&lt;C> &amp; {     loading?: boolean     disabled?: boolean   }  export function Button&lt;C extends BaseButtonComponent = 'button'>({   className,   loading,   disabled,   ...props }: ButtonProps&lt;C>) {   return (     &lt;BaseButton&lt;C>       className={clsx(         styles.button,         {           [styles.loading]: loading,           [styles.disabled]: disabled,         },         className,       )}       {...(props as BaseButtonProps&lt;C>)}     \/>   ) } <\/code><\/pre>\n<ol>\n<li>\n<p>\u041e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <code>BaseButton<\/code><\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u043f\u044b <code>disabled<\/code> \u0438 <code>loading<\/code>, \u0442.e. \u0442\u0438\u043f <code>ButtonProps<\/code> \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u0442\u0438\u043f <code>BaseButtonProps<\/code><\/p>\n<\/li>\n<li>\n<p>\u0422\u0438\u043f <code>BaseButtonProps<\/code> \u0442\u0430\u043a \u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u043c, \u0447\u0442\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0442\u0438\u043f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043e\u0442 <code>BaseButtonComponent<\/code><\/p>\n<\/li>\n<li>\n<p>\u0422.\u043a. <code>BaseButton<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u043c, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <code>Button<\/code> \u0442\u043e\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u043c \u0442\u043e \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u0442\u0438\u043f BaseButton \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u043c \u043e\u0442 <code>Button<\/code> \u0442\u0430\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c: <code>&lt;BaseButton&lt;C><\/code> \u0438\u043d\u0430\u0447\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 ts \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u043e\u0442 \u043d\u0435\u0433\u043e \u0445\u043e\u0442\u0438\u043c<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f <code>disabled<\/code> \u0438\u043b\u0438 <code>loading \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c<\/code> \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0442\u0438\u043b\u0438 \u043d\u0430\u0448\u0435\u0439 \u043a\u043d\u043e\u043f\u043a\u0435<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043b\u0438\u0448\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u0438\u043b\u0435\u0439, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0438\u0445 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u0442\u0438\u043b\u0438 \u043a\u043d\u043e\u043f\u043a\u0438 \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>.button {   outline: none;   border: none;   position: relative;   display: flex;   align-items: center;   justify-content: center;   min-height: 60px;   padding: 0 20px;   font-size: 16px;   font-weight: 500;   text-align: center;   text-decoration: none;   color: #fff;   background-color: #2196f3;   border-radius: 10px;   cursor: pointer;   transition: background-color 0.2s ease-in-out;    &amp;:hover {     background-color: #1976d2;     color: #fff;   }    &amp;:focus {     outline: none;     box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);   }    &amp;:active {     background-color: #0d47a1;     color: #fff;   }    &amp;.disabled, &amp;.loading {     background-color: grey;     pointer-events: none;      &amp;:hover {       background-color: grey;     }      &amp;:focus {       box-shadow:none;     }   }    &amp;.loading {     &amp;:after {       content: \"\";       position: absolute;       top: 6px;       left: 6px;       width: 6px;       height: 6px;       border-radius: 50%;       border: 2px solid #fff;       border-top-color: transparent;       animation: loading 0.8s linear infinite;     }   } }  @keyframes loading {   to { transform: rotate(360deg); } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0439 \u043a\u043d\u043e\u043f\u043a\u0438<\/h3>\n<ul>\n<li>\n<p>\u041e\u0431\u044b\u0447\u043d\u0430\u044f \u043a\u043d\u043e\u043f\u043a\u0430<\/p>\n<pre><code>&lt;Button onClick={showAlert}>Hello! It's button!&lt;\/Button><\/code><\/pre>\n<\/li>\n<li>\n<p>\u0421\u0441\u044b\u043b\u043a\u0430<\/p>\n<pre><code>&lt;Button   component={'a'}   target=\"_blank\"   href=\"https:\/\/www.google.ru\/\" >   It's Google link! &lt;\/Button><\/code><\/pre>\n<\/li>\n<li>\n<p>\u0420\u043e\u0443\u0442\u0435\u0440 Link<\/p>\n<pre><code>&lt;Button component={Link} to=\"\/link-route\">   It's router link! &lt;\/Button><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<h3>C\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 codesandbox \u0438 github<\/h3>\n<p><a href=\"https:\/\/codesandbox.io\/s\/eager-parm-f76hhy?file=\/src\/App.tsx\" rel=\"noopener noreferrer nofollow\">codesandbox<\/a> &#8212; \u043a\u043b\u0438\u043a\u0430\u0439\u0442\u0435 \u043f\u043e \u043a\u043d\u043e\u043f\u043a\u0430\u043c, \u044e\u0437\u0430\u0439\u0442\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043d\u043e\u043f\u043e\u043a<br \/><a href=\"https:\/\/github.com\/finesunes\/dynamic-button\" rel=\"noopener noreferrer nofollow\">github<\/a><\/p>\n<h3>\u041f\u043e\u0441\u043b\u0435\u0441\u043b\u043e\u0432\u0438\u0435<\/h3>\n<p>\u0418\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0438\u043f\u0430 <code>ButtonBaseProps<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443 \u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f<\/p>\n<pre><code>type DistributiveOmit&lt;T, K extends keyof any> = T extends any   ? Omit&lt;T, K>   : never<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u044f \u0432\u0430\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0438\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0447\u0442\u043e \u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c &#8212; \u0432\u044d\u043b\u043a\u0430\u043c \u0442\u0443 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0441<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/721862\/\"> https:\/\/habr.com\/ru\/post\/721862\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-346625","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346625","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=346625"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346625\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=346625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=346625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=346625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}