Pablo Duranti Pablo Duranti - 1 month ago 7x
React JSX Question

JSX- How can I manipulate strings in JSX?

I have a string in a JSX file that I have to manipulate this way:

Let's suppose I have the following string with this value

medical_specialty = "Plastic Surgery"

I need to do this:

medical_specialty.replace(' ', '-').toLowerCase()

to transform it to

Do I have full JavaScript syntax in JSX files?


You can use this sysntax in JSX files.
For example, using react:

  render() {
    let medical_specialty = "Plastic Surgery"

    medical_specialty = medical_specialty.replace(' ', '-').toLowerCase()

    return (
            { medical_specialty }

As Dave Newton said, JSX is nothing more than a reprocessor step that adds XML syntax to JavaScript.