React project tutorial code example
Example 1: command to create react app
npx create-react-app my-app
cd my-app
npm start
Example 2: how to create a new react app
npx create-react-app your-project-name
Example 3: reactjs basic example
const user = {
name: "zidane",
email: '[email protected]'
};
const element = <h1> {user.name} exist email: {user.email} </h1>;
const element2 =
<div className="heading">
<h1> {user.name} </h1>
<h1> {user.email} </h1>
</div>;
var numbers = [1,2,3,4];
var doubleNumbers = numbers.map(function(num){
return num * 2 + "; ";
})
var doubleNumberArrowFunction = numbers.map((num) => num * 3 + "; ");
var element3 =
<div>
Double numbers: {doubleNumberArrowFunction}
</div>;
ReactDOM.render(
element3,
document.getElementById('root')
);
.heading {
padding: 10px;
color: white;
background-color: green;
}
Example 4: react quick tutorial
ReactDOM.render(
<Hello />,
document.getElementById("root")
);