In my website I would like to display the phone number, and I would like to let the phone number be clickable when it is being accessed by the mobile website.
The following is the snippet of the code:
class MyGrid extends React.Component {
constructor(props) {
super(props);
this.state = { phone: "123" };
}
render() {
return (
<div>
<div className="d-block d-sm-none">
<a href={"tel:" + this.state.phone}>
<p className="footer-subheading text-link">{this.state.phone}</p>
</a>
</div>
<div className="d-none d-sm-block">
<p className="footer-subheading">{this.state.phone}</p>
</div>
</div>
);
}
}
// Render it
ReactDOM.render(
<MyGrid />,
document.getElementById("react")
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<div id="react"></div>
The first part would be displayed on phone (the phone number is clickable) and the second part shows on tablet and up (only text). Although there is only one phone number is displayed, the search engine would warn me for having duplicated phone number. I would like to see if it can be solved in different way.
Thanks in advance.