Skip to content

Commit 7b2053d

Browse files
committed
experimenting with back4app
1 parent 8b8e140 commit 7b2053d

19 files changed

+5410
-1
lines changed

lessons/03-persistence/03-persistence.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ const dummyData = [
328328

329329
// Fetch tweets from the database
330330
app.get("/api/tweets", (_, res) => {
331-
response.json(dummyData);
331+
res.json(dummyData);
332332
});
333333
```
334334

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
public/bundle.js
2+
node_modules
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2017 Jenn Schiffer
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: npm start
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Starter React App on Glitch
2+
===========================
3+
4+
This app is a very small scaffold to get you started using React and Webpack.
5+
6+
It's been copied by @starakaj for your enjoyment. You can find the original at https://glitch.com/~starter-react.
7+
8+
This project relates to video 2 of 5 in the [React Starter Kit](https://glitch.com/react-starter-kit) video series.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const React = require("react");
2+
const ReactDOM = require("react-dom");
3+
4+
/* Import Components */
5+
const RootComponent = require("./components/RootComponent");
6+
7+
ReactDOM.render(<RootComponent/>, document.getElementById("main"));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const React = require("react");
2+
3+
function ClockFace(props) {
4+
5+
const [date, setDate] = React.useState(new Date());
6+
7+
// This will be called whenever the component renders, but because we pass an empty
8+
// array as the second argument, it will only be called once, when the component
9+
// first renders.
10+
React.useEffect(() => {
11+
12+
const timerId = setInterval(() => {
13+
setDate(new Date);
14+
}, 1000);
15+
16+
// By returning a function from useEffect, we tell React that we'd like this
17+
// function called when the component is unmounted
18+
return () => { clearInterval(timerId) };
19+
20+
}, []);
21+
22+
let prefix = "";
23+
let postfix = ""
24+
if (props.language === "en") {
25+
prefix = "It is";
26+
postfix = "o'clock";
27+
} else if (props.language === "fr") {
28+
prefix = "Il est";
29+
postfix = "heures";
30+
}
31+
32+
return (
33+
<p>{prefix} {date.getHours()}:{date.getMinutes()}:{date.getSeconds()} {postfix}</p>
34+
);
35+
}
36+
37+
module.exports = ClockFace;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// DumbTwitter.jsx
2+
const React = require('react');
3+
const DumbTwitterForm = require("./DumbTwitterForm");
4+
const DumbTwitterList = require("./DumbTwitterList");
5+
6+
/* the main page for the index route of this app */
7+
const DumbTwitter = function() {
8+
return (
9+
<div>
10+
<h1>Dumb Twitter</h1>
11+
<DumbTwitterForm />
12+
<DumbTwitterList />
13+
</div>
14+
);
15+
}
16+
17+
module.exports = DumbTwitter;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// DumbTwitterForm.jsx
2+
const React = require('react');
3+
4+
const DumbTwitterForm = function() {
5+
return (
6+
<div>
7+
This is where the dumb Twitter form will go.
8+
</div>
9+
);
10+
}
11+
12+
module.exports = DumbTwitterForm;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const { useState, useEffect } = require('react');
2+
const React = require('react');
3+
4+
const DumbTwitterList = function() {
5+
6+
const [tweets, setTweets] = useState([]);
7+
8+
const listElements = tweets.map((tweet, idx) => {
9+
return <p key={idx}> {`${tweet.user}: ${tweet.message}`} </p>;
10+
});
11+
12+
async function fetchTweets() {
13+
const rawData = await fetch("api/tweets");
14+
const body = await rawData.json();
15+
setTweets(body);
16+
}
17+
18+
useEffect(() => {
19+
fetchTweets();
20+
}, []);
21+
22+
return (
23+
<div>
24+
{listElements}
25+
</div>
26+
);
27+
}
28+
29+
module.exports = DumbTwitterList;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const React = require("react");
2+
const DumbTwitter = require("./DumbTwitter");
3+
4+
/* the main page for the index route of this app */
5+
const RootComponent = function() {
6+
return (
7+
<DumbTwitter />
8+
);
9+
}
10+
11+
module.exports = RootComponent;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Starter React</title>
5+
<meta name="description" content="A cool thing made with React + Express">
6+
<meta charset="utf-8">
7+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
8+
<meta name="viewport" content="width=device-width, initial-scale=1">
9+
<link rel="stylesheet" href="style.css">
10+
</head>
11+
<body>
12+
13+
<div id="main">
14+
<!-- the hello world app will be in here! -->
15+
</div>
16+
17+
<!-- bundle all the scripts! thanks to webpack -->
18+
<script type="text/javascript" src="/bundle.js"></script>
19+
</body>
20+
</html>

0 commit comments

Comments
 (0)