INFO 253A: Frontend Web Architecture
Kay Ashaolu
<ul id="todos">
<li>Task 1</li>
<li>Task 2</li>
</ul>
src/index.js
import React from "react";
import ReactDOM from "react-dom";
const jsx_element = <h1>Hello, world!</h1>;
const dom_element = document.getElementById('root');
ReactDOM.render(jsx_element, dom_element);
src/index.html
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<div id="root"></div>
</body>
</html>
src/index.js
let formatName = (user) => {
return user.firstName + ' ' + user.lastName;
}
const user = {
firstName: 'Harper',
lastName: 'Perez'
};
const element = (
<h1>
Hello, {formatName(user)}!
</h1>
);
ReactDOM.render(
element,
document.getElementById('root')
);
src/index.js
import React from "react";
import ReactDOM from "react-dom";
function tick() {
const element = (
<div>
<h1>Hello, world!</h1>
<h2>It is {new Date().toLocaleTimeString()}.</h2>
</div>
);
ReactDOM.render(element, document.getElementById('root'));
}
setInterval(tick, 1000);
import React from "react";
import ReactDOM from "react-dom";
function FormatName(props) {
return (
<h1>
Hello, {props.firstName} {props.lastName}!
</h1>
);
}
ReactDOM.render(
<FormatName firstName="Kay" lastName="Ashaolu" />,
document.getElementById('root')
);
<FormatName firstName="Kay" lastName="Ashaolu" />,