React Basic :
To create a react project you need to install node js first.
Download node js from this link https://nodejs.org/en/
After successfully installing node js install react js by these commands, open your terminal and run these commands.
Now your react app will launch after running npm start command.
What is JSX :
Inside react if we want to show a H1 tag without JSX then we need to write these long syntax.
Inside index.js file comment out the ReactDOM.render and create a element and render it inside the root id html element.
Output for the above code is
this way JSX works internally to create elements.
JSX format :
For one heading element it is easy to initialize but what happen when you have to write a lot of html code, Its complicated write React.createElement code for all html code.
Babel is a compiler used in react js for JSX conversion.
Now the same above output you can get with JSX by writing simple html code.
Now simple html h1 tag can be used inside this render function. This code writing inside the render function is JSX.
lets understand with another file.
create a Demo.js file inside the src folder
This is the code inside the Demo.js file
This above code represent JSX.
Now we will import this file inside index.js and use it inside the ReactDOM.render.
This will generate same output with text demo data.
That’s all for this post, feel free to comment if you have any question.
This Post Has One Comment