InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

React Tutorials

  • Overview
  • Hello world (jsx)
  • jsx to javascript (babel cli)
  • jsx offline transformation
  • Hello world (javascript)
  • click hander (jsx)
  • click handler (javascript)
  • clock example
  • ajax
  • React FAQ
 
  • Home
  • > Tutorials
  • > Javascript
  • > React

React jsx hello world with offline transformation

on Feb 10, 2016

React JSX code can be compiled offline to transform into javascript code. This eliminates need to include babel code in browser. To see how it works in browser without offline transformation, you can visit JSX hello world. Here are the steps to do offline transformation in hello world example.

  1. Create jsx-hello.js in src directory with the following content.
    ReactDOM.render(
      <h1>Hello world</h1>,
      document.getElementById('hello')
    );
    
  2. Convert src/jsx-hello.js into compiled and transformed build/jsx-hello.js using the following command. You can visit ReactJS – convert jsx to javascript using babel cli for babel installation instructions.

    $ babel --presets react src --out-dir build
    src/jsx-hello.js -> build/jsx-hello.js
    $ cat build/jsx-hello.js
    ReactDOM.render(React.createElement(
      'h1',
      null,
      'Hello world'
    ), document.getElementById('hello'));
    
  3. Here is the html code which makes use of generated jsx-hello.js file in build dir.
    <script src="https://fb.me/react-0.14.7.js"></script>
    <script src="https://fb.me/react-dom-0.14.7.js"></script>
    
    <div id="hello"></div>
    <script src="/demo2/react/build/jsx-hello.js"></script>
    
    refresh done
    try it online

Suggested posts:

  1. PHP array map example
  2. Python xrange examples
  3. Comic strip – Startup and losses
  4. React basic clock example using setInterval
  5. React javascript render hello world
  6. React component tutorial with click handler – javascript version
  7. jquery ajax – post form having file uploads
  8. CSS transform – skew (skewX and skewY)
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Javascript, React, Tutorials, Web Development
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress