J
J
jslby2019-06-05 19:17:36
JavaScript
jslby, 2019-06-05 19:17:36

How to substitute variables into a string in React?

Hello!
There is an API. It produces the following object:

{test: 'test string test string test {var} string test string test string '}

There is a var variable in the string that needs to be replaced with the current state of the component, this.state.var
How to implement this replacement and is it possible? You can change what the API would give {this.state.var}. The bottom line is that there is a line in which the variable is specified.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jslby, 2019-06-05
@jslby

So far I've only found this solution: https://www.npmjs.com/package/react-jsx-parser

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question