react example code
Example 1: React js tutorial
npx create-react-app my-app
cd my-app
cd src
# If you're using a Mac or Linux:
rm -f *
# Or, if you're on Windows:
del *
# Then, switch back to the project folder
cd ..
Example 2: reactjs basic example
// -------// -------// -------
// index.js
// -------// -------// -------
const user = {
name: "zidane",
email: '[email protected]'
};
const element = {user.name} exist email: {user.email}
;
const element2 =
{user.name}
{user.email}
;
var numbers = [1,2,3,4];
var doubleNumbers = numbers.map(function(num){
return num * 2 + "; ";
})
var doubleNumberArrowFunction = numbers.map((num) => num * 3 + "; ");
var element3 =
Double numbers: {doubleNumberArrowFunction}
;
ReactDOM.render(
element3,
//
//
// ,
document.getElementById('root')
);
// -------// -------// -------
// ------- index.css ------
// -------// -------// -------
.heading {
padding: 10px;
color: white;
background-color: green;
}
Example 3: react quick tutorial
ReactDOM.render(
,
document.getElementById("root")
);