0

I have created a project using create-react-app my class code is:

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

class App extends Component {
  render() {
    let x='&'
    return (
      <div className="App">
        <div className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h2>Welcome to React</h2>
        </div>
        <p className="App-intro">
          To get started, {x}edit <code>src/App.js</code> and save to reload.
        </p>
      </div>
    );
  }
}

export default App;

in output I am expecting & because of Which characters need to be escaped on HTML? as stated & becomes &amp; but getting & instead, as stated in official react document:

By default, React DOM escapes any values embedded in JSX before rendering them

But in my case this escaping is not working, can anyone please explain why??

Mayank Shukla
  • 100,735
  • 18
  • 158
  • 142
mathlearner
  • 7,509
  • 31
  • 126
  • 189
  • It automatically escape the & before rendering, what is not working here ? Look at this [fiddle](https://jsfiddle.net/b1fyvyg2/1/) – T4rk1n Jul 18 '17 at 07:02
  • "To get started, &edit src/App.js and save to reload. " instead of this i am expecting "To get started, &edit src/App.js and save to reload. ".because of escaping . – mathlearner Jul 18 '17 at 10:01

0 Answers0