Reputation: 56
The string text that will contain a placeholder for the link element to be placed: such as Please Click {0} to enter new Page
.
And the {0} will be replace with the Link element
Expected result:
Let say inside we want a clickable link (It can be other things/elements)
Please Click here <a href="https://somenewpage.com"> HERE </a> to enter new Page
The reason to do this is to support multi language because the position of placeholder could change to be in other position ( E.g. โปรดกดตรง {0} )
I just wonder is there any other ways to do this cleanly?
Thanks.
Upvotes: 1
Views: 130
Reputation: 468
Another way is, create a new component HyperLink
and call it with two props.
class Hyperlink extends React.Component {
render() {
return <a href={this.props.link}>{this.props.text}</h2>;
}
}
Then call Hyperlink
as follow
Please Click <Hyperlink link={href} text="HERE"/> to enter new Page
Upvotes: 1