
- ReactJS Tutorial
- ReactJS - Home
- ReactJS - Introduction
- ReactJS - Installation
- ReactJS - Features
- ReactJS - Advantages & Disadvantages
- ReactJS - Architecture
- ReactJS - Creating a React Application
- ReactJS - JSX
- ReactJS - Components
- ReactJS - Nested Components
- ReactJS - Using Newly Created Components
- ReactJS - Component Collection
- ReactJS - Styling
- ReactJS - Properties (props)
- ReactJS - Creating Components using Properties
- ReactJS - props Validation
- ReactJS - Constructor
- ReactJS - Component Life Cycle
- ReactJS - Event management
- ReactJS - Creating an Event−Aware Component
- ReactJS - Introduce Events in Expense Manager APP
- ReactJS - State Management
- ReactJS - State Management API
- ReactJS - Stateless Component
- ReactJS - State Management Using React Hooks
- ReactJS - Component Life Cycle Using React Hooks
- ReactJS - Layout Component
- ReactJS - Pagination
- ReactJS - Material UI
- ReactJS - Http client programming
- ReactJS - Form Programming
- ReactJS - Controlled Component
- ReactJS - Uncontrolled Component
- ReactJS - Formik
- ReactJS - Conditional Rendering
- ReactJS - Lists
- ReactJS - Keys
- ReactJS - Routing
- ReactJS - Redux
- ReactJS - Animation
- ReactJS - Bootstrap
- ReactJS - Map
- ReactJS - Table
- ReactJS - Managing State Using Flux
- ReactJS - Testing
- ReactJS - CLI Commands
- ReactJS - Building and Deployment
- ReactJS - Example
- Hooks
- ReactJS - Introduction to Hooks
- ReactJS - Using useState
- ReactJS - Using useEffect
- ReactJS - Using useContext
- ReactJS - Using useRef
- ReactJS - Using useReducer
- ReactJS - Using useCallback
- ReactJS - Using useMemo
- ReactJS - Custom Hooks
- ReactJS Advanced
- ReactJS - Accessibility
- ReactJS - Code Splitting
- ReactJS - Context
- ReactJS - Error Boundaries
- ReactJS - Forwarding Refs
- ReactJS - Fragments
- ReactJS - Higher Order Components
- ReactJS - Integrating With Other Libraries
- ReactJS - Optimizing Performance
- ReactJS - Profiler API
- ReactJS - Portals
- ReactJS - React Without ES6 ECMAScript
- ReactJS - React Without JSX
- ReactJS - Reconciliation
- ReactJS - Refs and the DOM
- ReactJS - Render Props
- ReactJS - Static Type Checking
- ReactJS - Strict Mode
- ReactJS - Web Components
- Additional Concepts
- ReactJS - Date Picker
- ReactJS - Helmet
- ReactJS - Inline Style
- ReactJS - PropTypes
- ReactJS - BrowserRouter
- ReactJS - DOM
- ReactJS - Carousel
- ReactJS - Icons
- ReactJS - Form Components
- ReactJS - Reference API
- ReactJS Useful Resources
- ReactJS - Quick Guide
- ReactJS - Useful Resources
- ReactJS - Discussion
ReactJS - React Without JSX
Let us learn how to use createElement to create react component instead of default JSX in this chapter.
What is JSX?
JSX is a JavaScript extension to create arbitrary HTML element using syntax similar to HTML. This will simplify the HTML document creation as well as easy to understand the document. React will convert the JSX into JavaScript object consisting of React's createElement function call before executing it.
It improves the performance of the application. Also, React allows the HTML document creation using pure createElement function without JSX as well. This enables the developer to directly create HTML document in a situation where JSX does not fit well.
What is createElement?
React.createElement is the core React API which is used to generate and render the HTML document. createElement method has three arguments,
component name
props as objects
inner content / children of the component
Here, children may refer an another component, again created using createElement. createElement can be nested to any level. The sample code to create a component using React.createElement is as follows −
React.createElement('h1', null, 'Hello World')
This will render the below mentioned HTML document
<h1>Hello World</h1>
Working example
Let us create a component BookListUsingCreateElement to learn and understand the createElement method.
First of all, create a new application using create-react-app
create-react-app myapp
Then, add a new component, BookListUsingCreateElement under components folder. The initial code is as follows −
import React from 'react' class BookListUsingCreateElement extends React.Component { constructor(props) { super(props); this.state = { list: ['C++ Programming', 'Java Programming', "JavaScript Programming"] }; } } export default BookListUsingCreateElement
Here, list is the initial collection of books available in the component.
Now, Let us render books using createElement in the render function as shown below.
render() { let content = React.createElement( 'ol', null, this.state.list.map( (item) => React.createElement('li', null, item) ) ) return content; }
Here, we have used createElement in two places. First of all, we used it to create the top-most layer of the component, which is ul HTML element. Second, we have used createElement multiple times to create the li element based on the books available in the list. We have used map function to loop over all books in the list and create a li element for each book using React.createElement('li', null, item) code.
Finally, the complete code of the component is as follows
import React from 'react' class BookListUsingCreateElement extends React.Component { constructor(props) { super(props); this.state = { list: ['C++ Programming', 'Java Programming', "JavaScript Programming"] }; } render() { let content = React.createElement( 'ol', null, this.state.list.map( (item) => React.createElement('li', null, item) ) ) return content; } } export default BookListUsingCreateElement
Let us use our newly create component through App.js as shown below −
import BookListUsingCreateElement from "./components/CreateElement/BookListUsingCreateElement"; function App() { return ( <div> <BookListUsingCreateElement /> </div> ); } export default App;
Now, run the app using below command
npm start
The application will start in the default browser and show below result

To Continue Learning Please Login