reactjs - Add dynamic phone Number in react - Stack Overflow

I create the component with the phone numberconst PhoneNumber = () => {return (<div>123-456-7

I create the component with the phone number

const PhoneNumber = () => {
  return (
    <div>123-456-7890</div>
  )
}

and I add it in href

<a href="tel: 123-456-789" title="Phone Number" className="transition"><PhoneNumber/></a>

how can I add in href="tel:123-456-789"

I create the component with the phone number

const PhoneNumber = () => {
  return (
    <div>123-456-7890</div>
  )
}

and I add it in href

<a href="tel: 123-456-789" title="Phone Number" className="transition"><PhoneNumber/></a>

how can I add in href="tel:123-456-789"

Share Improve this question asked Nov 16, 2024 at 6:09 Nazar KardanNazar Kardan 651 silver badge5 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Let me explain about your problem. You can change your code as my sample below

import React from 'react';

const PhoneNumber = ({ number }) => {
  return (
    <div>{number}</div>
  );
};

export default PhoneNumber;

Code for the component

import React from 'react';
import PhoneNumber from './PhoneNumber';

const App = () => {
  const phoneNumber = "123-456-7890";

  return (
    <div>
      <a href={`tel:${phoneNumber}`} title="Phone Number" className="transition">
        <PhoneNumber number={phoneNumber} />
      </a>
    </div>
  );
};

export default App;

Code for the main functions. With my samples you can assign your phone number dynamic rather than static.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745664452a4639039.html

相关推荐

  • reactjs - Add dynamic phone Number in react - Stack Overflow

    I create the component with the phone numberconst PhoneNumber = () => {return (<div>123-456-7

    5小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信