-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path12.jsx.spread.html
42 lines (39 loc) · 1012 Bytes
/
12.jsx.spread.html
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
<!DOCTYPE html>
<html>
<head>
<title>JSX spread attributes</title>
<meta charset="utf-8" />
<style>
body {
font-family: -apple-system, sans-serif;
}
</style>
</head>
<body>
<div id="app1"></div>
<div id="app2"></div>
<script src="react/react.js"></script>
<script src="react/react-dom.js"></script>
<script src="react/babel.js"></script>
<script type="text/babel">
const attr = {
href: "https://example.org",
target: "_blank",
};
function Example1() {
return (
<a href={attr.href} target={attr.target}>
Follow me
</a>
);
}
function Example2() {
// try both in babel playground
// return <a attr>Follow me</a>;
return <a {...attr}>Follow me</a>;
}
ReactDOM.render(<Example1 />, document.getElementById("app1"));
ReactDOM.render(<Example2 />, document.getElementById("app2"));
</script>
</body>
</html>