Update Mailto

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-09-06 14:32:19 +03:00
parent b855fd1f1d
commit 26e071bb3f

View File

@ -6,14 +6,14 @@ tags: components,beginner
Renders a link formatted to send an email.
- Destructure the component's props, use `email`, `subject` and `body` to create a `<a>` element with an appropriate `href` attribute.
- Render the link with `props.children` as its content.
- Render the link with `children` as its content.
```jsx
function Mailto({ email, subject, body, ...props }) {
const Mailto = ({ email, subject, body, children }) => {
return (
<a href={`mailto:${email}?subject=${encodeURIComponent(subject) || ''}&body=${encodeURIComponent(body) || ''}`}>{props.children}</a>
<a href={`mailto:${email}?subject=${encodeURIComponent(subject) || ''}&body=${encodeURIComponent(body) || ''}`}>{children}</a>
);
}
};
```
```jsx