React Without JSX – React (2024)

These docs are old and won’t be updated. Go to react.dev for the new React docs.

JSX is not a requirement for using React. Using React without JSX is especially convenient when you don’t want to set up compilation in your build environment.

Each JSX element is just syntactic sugar for calling React.createElement(component, props, ...children). So, anything you can do with JSX can also be done with just plain JavaScript.

For example, this code written with JSX:

class Hello extends React.Component { render() { return <div>Hello {this.props.toWhat}</div>; }}const root = ReactDOM.createRoot(document.getElementById('root'));root.render(<Hello toWhat="World" />);

can be compiled to this code that does not use JSX:

class Hello extends React.Component { render() { return React.createElement('div', null, `Hello ${this.props.toWhat}`); }}const root = ReactDOM.createRoot(document.getElementById('root'));root.render(React.createElement(Hello, {toWhat: 'World'}, null));

If you’re curious to see more examples of how JSX is converted to JavaScript, you can try out the online Babel compiler.

The component can either be provided as a string, as a subclass of React.Component, or a plain function.

If you get tired of typing React.createElement so much, one common pattern is to assign a shorthand:

const e = React.createElement;const root = ReactDOM.createRoot(document.getElementById('root'));root.render(e('div', null, 'Hello World'));

If you use this shorthand form for React.createElement, it can be almost as convenient to use React without JSX.

Alternatively, you can refer to community projects such as react-hyperscript and hyperscript-helpers which offer a terser syntax.

React Without JSX – React (2024)
Top Articles
Have The Reversals Slowed the SoCal Real Estate Recovery ??
Success Story: Chris Stewart of State Farm | SmartFinancial
This website is unavailable in your location. – WSB-TV Channel 2 - Atlanta
1970 Chevelle Ss For Sale Craigslist
Zitobox 5000 Free Coins 2023
Craigslist Nj North Cars By Owner
Whiskeytown Camera
Transformers Movie Wiki
Craigslist Dog Kennels For Sale
Ssefth1203
Walthampatch
Healing Guide Dragonflight 10.2.7 Wow Warring Dueling Guide
Toy Story 3 Animation Screencaps
The Grand Canyon main water line has broken dozens of times. Why is it getting a major fix only now?
Virginia New Year's Millionaire Raffle 2022
Labby Memorial Funeral Homes Leesville Obituaries
Silive Obituary
Gayla Glenn Harris County Texas Update
Is A Daytona Faster Than A Scat Pack
Vegas7Games.com
Laveen Modern Dentistry And Orthodontics Laveen Village Az
The EyeDoctors Optometrists, 1835 NW Topeka Blvd, Topeka, KS 66608, US - MapQuest
Reborn Rich Kissasian
fft - Fast Fourier transform
Top 20 scariest Roblox games
Lindy Kendra Scott Obituary
Big Boobs Indian Photos
Grove City Craigslist Pets
Grays Anatomy Wiki
Khatrimmaza
JD Power's top airlines in 2024, ranked - The Points Guy
Lehpiht Shop
Audi Q3 | 2023 - 2024 | De Waal Autogroep
Robot or human?
Great Clips On Alameda
آدرس جدید بند موویز
Best Weapons For Psyker Darktide
Etowah County Sheriff Dept
Andhra Jyothi Telugu News Paper
Indio Mall Eye Doctor
Flipper Zero Delivery Time
Disassemble Malm Bed Frame
Collision Masters Fairbanks
Elven Steel Ore Sun Haven
3500 Orchard Place
Samsung 9C8
Accident On 40 East Today
Fine Taladorian Cheese Platter
Gear Bicycle Sales Butler Pa
Diablo Spawns Blox Fruits
Minecraft Enchantment Calculator - calculattor.com
Competitive Comparison
Latest Posts
Article information

Author: Terrell Hackett

Last Updated:

Views: 6519

Rating: 4.1 / 5 (72 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Terrell Hackett

Birthday: 1992-03-17

Address: Suite 453 459 Gibson Squares, East Adriane, AK 71925-5692

Phone: +21811810803470

Job: Chief Representative

Hobby: Board games, Rock climbing, Ghost hunting, Origami, Kabaddi, Mushroom hunting, Gaming

Introduction: My name is Terrell Hackett, I am a gleaming, brainy, courageous, helpful, healthy, cooperative, graceful person who loves writing and wants to share my knowledge and understanding with you.