-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path08-jsx-interpolation.html
More file actions
27 lines (25 loc) · 869 Bytes
/
Copy path08-jsx-interpolation.html
File metadata and controls
27 lines (25 loc) · 869 Bytes
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
<body>
<div id="root"></div>
<script src="https://unpkg.com/react@16.12.0/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16.12.0/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@babel/standalone@7.8.3/babel.js"></script>
<script type="text/babel">
// In jsx interpolation we must have to write simple expression. we can't write if else statement, for loop etc.
function CharacterCount({ text }) {
return (
<div>
{`The text "${text}" has `}
{text.length ? <strong>{text.length}</strong> : "No"}
{" characters"}
</div>
);
}
const element = (
<>
<CharacterCount text="Hello World" />
<CharacterCount text="" />
</>
);
ReactDOM.render(element, document.getElementById("root"));
</script>
</body>