Pablo Duranti Pablo Duranti - 1 year ago 191
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download