Skip to content

Instantly share code, notes, and snippets.

@RubaXa
Last active August 27, 2019 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RubaXa/2b38f7a8490c7d66cb1cd1ed9cebb0af to your computer and use it in GitHub Desktop.
Save RubaXa/2b38f7a8490c7d66cb1cd1ed9cebb0af to your computer and use it in GitHub Desktop.
Poor slots. Describe.
type LoginFormProps = {
header?: boolean;
title?: React.ReactNode;
titleEl?: React.ReactNode; // ⬅️ заметьте, я не глупый и делаю универсально
email?: string;
password?: string;
}
function LoginForm(props: LoginFormProps) {
const titleEl = props.titleEl || <h2/>;
const jsxTitle = React.cloneElement(
titleEl,
titleEl.props,
props.title || <>Вход</>,
);
return (
<Form>
{props.header !== false && <div className="header">
{jsxTitle}
</div>}
<div className="fields">
<Input name="email" value={props.email} />
<Input name="password" value={props.password} />
</div>
<div className="controls">
<Button kind="primary"/>
</div>
</Form>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment