Day 2 :Creating Our Own React Library and JSX
So React uses its parallel dom in which it injects the HTML elements and renders the page
so for that, we need to know how React converts an HTML element (back of the scene)
also, we need a render function to merge the dom element in the main container
-
so we have done this manually, obviously, React might use some different syntax for the same but as of now we are capable of forming our library
Let's now pick a project and analyze it
so in 01vitereact, we have two files main. jsx and App.jsx
in which we are rendering an APP inside the main.jsx
whose definition is present inside the APP.js
what is exactly an APP????
-
one more thing since the App is just a function can we simply write APP()
that's what we call a simple function, right?
yes we can do this but it's not a good practice to do as there are some internal functions or optimization involved
-
it will give us the error that might be reacting was expecting some different type of syntax
so if it's not the right syntax what it would be ??
-
React uses its own property called React.createElement()
Now let's see how the injection of the variable takes place
by using {} syntax