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
Public and Private Keys: What Are They? | Gemini
Expired Card: What It is, Benefits of Replacing it
Mybranch Becu
Exclusive: Baby Alien Fan Bus Leaked - Get the Inside Scoop! - Nick Lachey
My Arkansas Copa
Thor Majestic 23A Floor Plan
El Paso Pet Craigslist
Ets Lake Fork Fishing Report
Practical Magic 123Movies
<i>1883</i>'s Isabel May Opens Up About the <i>Yellowstone</i> Prequel
Kristine Leahy Spouse
Slapstick Sound Effect Crossword
Directions To Lubbock
Mndot Road Closures
Nichole Monskey
Simple Steamed Purple Sweet Potatoes
OpenXR support for IL-2 and DCS for Windows Mixed Reality VR headsets
House Party 2023 Showtimes Near Marcus North Shore Cinema
Becu Turbotax Discount Code
Panorama Charter Portal
Baywatch 2017 123Movies
Dirt Removal in Burnet, TX ~ Instant Upfront Pricing
Huntersville Town Billboards
Hermitcraft Texture Pack
Katie Sigmond Hot Pics
2013 Ford Fusion Serpentine Belt Diagram
Plaza Bonita Sycuan Bus Schedule
Naval Academy Baseball Roster
Silky Jet Water Flosser
Jcp Meevo Com
Breckiehill Shower Cucumber
Watson 853 White Oval
Cona Physical Therapy
Unreasonable Zen Riddle Crossword
Vivification Harry Potter
Southtown 101 Menu
Mrstryst
Mumu Player Pokemon Go
Wasmo Link Telegram
Kattis-Solutions
Gwen Stacy Rule 4
Bee And Willow Bar Cart
Wattengel Funeral Home Meadow Drive
Elizaveta Viktorovna Bout
Mcgiftcardmall.con
Dr Adj Redist Cadv Prin Amex Charge
Craigslist Com St Cloud Mn
2013 Honda Odyssey Serpentine Belt Diagram
French Linen krijtverf van Annie Sloan
2487872771
2000 Fortnite Symbols
Convert Celsius to Kelvin
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.