Files
30-seconds-of-code/snippets/callto.md
Angelos Chalaris f1ce423d01 Kebab file names
2023-04-27 22:04:15 +03:00

27 lines
613 B
Markdown

---
title: Callable telephone link
tags: components
author: chalarangelo
unlisted: true
cover: rabbit-call
firstSeen: 2020-10-04T00:07:37+03:00
lastUpdated: 2021-01-04T12:32:47+02:00
---
Renders a link formatted to call a phone number (`tel:` link).
- Use `phone` to create a `<a>` element with an appropriate `href` attribute.
- Render the link with `children` as its content.
```jsx
const Callto = ({ phone, children }) => {
return <a href={`tel:${phone}`}>{children}</a>;
};
```
```jsx
ReactDOM.createRoot(document.getElementById('root')).render(
<Callto phone="+302101234567">Call me!</Callto>
);
```