-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.jsx
56 lines (44 loc) · 1.33 KB
/
main.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App.jsx";
function MyApp() {
return (
<>
<h1>Custom App!</h1>
</>
);
}
// ReactDOM.createRoot(document.getElementById("root")).render(
// <App />
// // MyApp() // also we invoke like this beacuse it's also a function but we can't do this beacuse of problem on optimization
// // <MyApp />
// );
// (custom react object)
// const reactElement = {
// type: "a",
// props: {
// herf: "https://google.com",
// target: "_blank",
// },
// children: "Visit Google",
// };
// ReactDOM.createRoot(document.getElementById("root")).render(reactElement);
// create new method
const anotherElement = (
<a href="https://google.com" target="_blank">
Visit Google
</a>
);
// ReactDOM.createRoot(document.getElementById("root")).render(anotherElement);
// make element based on react method // have a special syntax
const anotherUser = "Divyanshu";
const reactElement = React.createElement(
"a", // first parameter is tag
{
href: "https://google.com", // second parameter is object , add prop
target: "_blank",
},
"click me to visit google", // direct Text
anotherUser // you can't use condition statement in elevated expressions
);
ReactDOM.createRoot(document.getElementById("root")).render(reactElement);