Simple React Hello World Example

Simple React Hello World Example

Today, We want to share with you Simple React Hello World Example.In this post we will show you react js basics example tutorial, hear for react js examples for beginners we will give you demo and example for implement.In this post, we will learn about react js sample project step by step with an example.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

Snippet Contents

Simple React Hello World Example

There are the Following The simple About Simple React Hello World Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop understanding react js, so the install react and create react app Directory structures for this example is following below.

React js sample project step by step

It simple displays a heading saying “Hello, world!” on the web page.

Syntex

ReactDOM.render(
  <h1>Hello, world!</h1>,
  document.getElementById('root')
);

Step 1: Run these commands:

npm i
npm start

We only have to simple run npm i the first time using CMD.

Step 2: package.json

{
  "name": "hello-react",
  "version": "1.0.0",
  "description": "pakainfo - Simple React Hello World",
  "main": "index.js",
  "scripts": {
    "start": "browserify -t babelify --outfile public/firstweb-app.js src/hello.jsx && echo 'Open http://localhost:8000/ in your browser' && (cd public ; python -m SimpleHTTPServer)",
    "watch": "watchify -v -t babelify --outfile public/firstweb-app.js src/hello.jsx"
  },
  "author": "",
  "license": "ISC",
  "repository": "none",
  "devDependencies": {
    "babelify": "^6.3.0",
    "browserify": "^11.2.0",
    "watchify": "^3.4.0"
  },
  "dependencies": {
    "react": "^0.14.3",
    "react-dom": "^0.14.3"
  }
}

Step 3: public_index.html

<!DOCTYPE html>
<html>
  <head>
    <title>Simple React Hello World - pakainfo.com</title>
  </head>
  <body>
    <h1>pakainfo.com - Simple React Hello World</h1>
    <div id="root"></div>
    <script src="/firstweb-app.js"></script>
  </body>
</html>

Step 4: src_hello.jsx

import React from "react";
import ReactDOM from "react-dom";

const Hello = function(name) {
  return (
    <div>Hello, {name}</div>
  );
};

const view = Hello("Will");

const element = document.getElementById("root");
ReactDOM.render(view, element);

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Simple React Hello World Example.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1.   PHP Laravel 5.7 Get IP Address Example
  2.   Dynamically Add Remove multiple input fields in PHP MYSQL with Jquery Ajax
  3.   WPML Display Different Logo in each language
  4.   PHP crud Mysqli Select Insert Update and Delete query
  5.   ReactJS State Example Tutorial
  6.   React JSX Basics Step By Step
  7.   Laravel 6 Join Clause Example Tutorial
  8.   WordPress Security Tricks to Secure WordPress Website
  9.   Laravel Return Ajax JSON Response Example
  10.   jQuery Add Remove Class on mouseOver mouseOut