Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React JSX in Depth #8

Open
MauricioAires opened this issue Feb 12, 2023 · 0 comments
Open

React JSX in Depth #8

MauricioAires opened this issue Feb 12, 2023 · 0 comments

Comments

@MauricioAires
Copy link
Owner

As we have seen in this article React.js (Introduction and Working), how React works, Breaking down our application into smaller reusable parts which we call components. These components are tree-like HTML or Component structure. In that article, we have seen how to create elements using createElement in react. But if we’ve to work with React’s createElement method just to create elements then it would be fine for demo purposes or for a small app but not for a large application. You just should not use it.

React.createElement is fine to create elements for a small app or for demo purposes but not for a large salable app because it would be very hard to maintain or debug. we’ve to call React.createElement method every time for creation of React element even if it just a span tag with no attributes.

You can build whole application using React.createElement method(which I don’t recommend).

Sometimes new developer get confuses JSX with HTML because they look very familiar. JSX is just another way of creating React elements. The react team created JSX to make it more readable like HTML and XML. So that we don’t have to create React elements manually with the createElement method. let say you want to create a button with class btn, btn-primary.

If we shouldn’t use createElement use JSX. It is JavaScript and XML. It is a JavaScript extension that allows us to define React elements using a tag-based style syntax within our JS code. How cool is that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant