Can React be used without JSX?

753 Views Asked by At

jsx is used tactically in React and helps developers understand React components by viewing the code in more detail. Now the question is, is it possible to use other methods such as using simple functions or using other libraries such as preact or inferno in the react library?

With the searches that I did, I think that other libraries such as preact or inferno can be used in the React library. Is this conclusion correct?

1

There are 1 best solutions below

0
On

Yes, we can use react without jsx for that we need to use React.createElement() everywhere in code. So, anything you can do with JSX can also be done with just React.createElement().

you can do this because jsx is being converted into React.createElement() using Babel compiler

Example:

JSX :-

<div>Hello Jsx</div>

React.createElement :-

React.createElement('div', null, 'Hello');