Irfan Shaikh
Irfan Shaikh

Reputation: 125

Browsers can not read jsx syntax

JSX is an XML/HTML-like syntax used by React that extends ECMAScript so that XML/HTML-like text can co-exist with JavaScript/React code. ... Unlike HTML why can't browsers read jsx

Upvotes: 0

Views: 3556

Answers (4)

aximas
aximas

Reputation: 9

Yeah, browsers can't read JSX syntax. First of all jsx files transpiled via Babel to native js in bundle.js If you know you can find index.html in public folder of project, only this folder is native for browser

Upvotes: 0

user14383343
user14383343

Reputation:

React uses JSX (JavaScript eXtension) that allows us to write JavaScript that looks like HTML. But JSX is not valid JavaScript, web browser can't read it directedly. So, if JavaScript files contain JSX, that file will have to be transpired, you need a transpire to convert your JSX to regular java script that browser can understand.

The most widely used transpire right now is Babel

Upvotes: 2

Amitesh mani tiwari
Amitesh mani tiwari

Reputation: 549

In one liner answer will, Browser reads only Javascript objects but JSX is not regular Javascript object. So we need engine to convert into Javascript regular objects(bebel for it).

Upvotes: 0

JupiterAmy
JupiterAmy

Reputation: 384

Browsers cannot read JSX because there is no inherent implementation for the browser engines to read and understand it. You can use babel to transform your jsx into native javascript and HTML which browser can understand.

Upvotes: 4

Related Questions