-
Notifications
You must be signed in to change notification settings - Fork 154
Expand file tree
/
Copy pathApp.jsx
More file actions
81 lines (68 loc) · 2.23 KB
/
Copy pathApp.jsx
File metadata and controls
81 lines (68 loc) · 2.23 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { useState } from "react"
import { useEffect } from "react"
import { StrictMode } from 'react'
import { Container, Typography } from "@mui/material";
import { createRoot } from 'react-dom/client'
import { Header } from "./Header"
import { ThoughtForm } from "./ThoughtForm"
import { ThoughtList } from "./ThoughtList"
import { ColorFilter } from "./ColorFilter"
import { ThoughtGrid } from "./ThoughtGrid"
import { LoadingSpinner } from "./LoadingSpinner";
import { LoginForm } from "./LoginForm";
import { SignupForm } from "./SignupForm";
import { EditButton } from "./EditButton"
import { Form } from "./Form";
import { Card } from "./Card";
import { Index } from "./Index";
import { Css } from "./Css";
import { Animation } from "./Animation";
// Removed duplicate declaration of App component
export const App = () => {
const [count, setCount] = useState(0);
useEffect(() => {
const handleScroll = () => {
console.log('scrolled!');
};
window.addEventListener('scroll', handleScroll);
return () => {
window.removeEventListener('scroll', handleScroll);
};
}, []);
useEffect(() => {
const controller = new AbortController();
fetch('https://happy-thoughts-ux7hkzgmwa-uc.a.run.app/thoughts', { signal: controller.signal })
.then(response => response.json())
.then(data => console.log(data));
const intervalId = setInterval(() => {
fetch('https://happy-thoughts-ux7hkzgmwa-uc.a.run.app/thoughts', { signal: controller.signal })
.then(response => response.json())
.then(data => console.log(data));
console.log('This runs every second');
}, 1000);
return () => {
clearInterval(intervalId);
controller.abort();
};
}, []);
return (
<div>
<button onClick={() => setCount(count + 1)}>
Increase count
</button>
<button onClick={() => setCount(count - 1)}>
Decrease count
</button>
<button
onClick={() => setCount(0)}
disabled={count === 0}>
Reset
</button>
<button onClick={() => setCount(count * 2)}>
Multiply
</button>
<p>Count: {count}</p>
{count > 140 && <p>You hit 140!</p>}
</div>
);
};