mithelan
mithelan

Reputation: 190

Replace Text with Content Editable in ReactJS

const Str = 'Your name +++Vijay+++Welcome to hello world '

I want to replace Vijay with reactJS content editable, where i can change the name.

Upvotes: 0

Views: 108

Answers (2)

Anhdevit
Anhdevit

Reputation: 2104

I think you can use the replace function https://www.w3schools.com/jsref/jsref_replace.asp

let Str = 'Your name +++Vijay+++Welcome to hello world '
Str = Str.replace("Vijay", "something you want") 

Upvotes: 0

Anh Tuan
Anh Tuan

Reputation: 1143

you can use string template to do that try

const changeStr = (name = "USER_NAME") => `Your name ${name} Welcome to hello world`

then

changeStr('Vijay')

Upvotes: 1

Related Questions