JSX-JS XML

MOHD RAZA
1 min readDec 12, 2022

--

  1. JSX stands for JavaScript XML.
    const element = <h1>Hello, world!</h1>;

2. JSX allows us to write HTML elements in JavaScript and place them in the DOM without any createElement() and/or appendChild() methods. JSX converts HTML tags into react elements.

3. Babel and prettier is a tool whereas Babel used for

.Transform syntax

  • Polyfill features that are missing in your target environment (through a third-party polyfill such as core-js)
  • Source code transformations (code mods)

prettie -An opinionated code formatter.

4. why babel is used in jsx-

Babel can convert JSX syntax! Check out our React preset to get started. Use it together with the babel-sublime package to bring syntax highlighting to a whole new level.

export default function DiceRoll(){
const [num, setNum] = useState(getRandomNumber());

const getRandomNumber = () => {
return Math.ceil(Math.random() * 6);
};

return (
<div>
Your dice roll:
{num}
</div>
);
};

--

--

No responses yet