Create Callto.md

This commit is contained in:
Azan Bin Zahid
2020-10-04 02:07:37 +05:00
committed by GitHub
parent b5a4750518
commit a2eaa2fbe5

26
snippets/Callto.md Normal file
View File

@ -0,0 +1,26 @@
---
title: Callto
tags: components,beginner
---
Renders a link formatted to dial a phone number.
- Destructure the component's props, 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.render(
<Callto phone="+923081734339">
Call me!
</Callto>,
document.getElementById('root')
);
```