-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
60 lines (48 loc) · 1.31 KB
/
App.js
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
import Navbar from "./components/Navbar.js";
import React, { useState } from "react";
import TextForm from "./components/TextForm.js";
import Alert from "./components/Alert.js";
import About from "./components/About.js";
import { BrowserRouter, Routes, Route } from "react-router-dom";
//export default App;
//Data Flows from App.js to TextForm.js and Navbar.js to TextForm.js and Navbar.js to App.js.
function App() {
document.body.style.backgroundColor = "#2C2F33";
document.body.style.color = "#ffff";
const [alert, setAlert] = useState(null);
const showAlert = (message, type) => {
setAlert({
msg: message,
type: type,
});
setTimeout(() => {
setAlert(null);
}, 2000);
};
return (
<>
<Navbar
title="TextUtils"
aboutText="About This App"
/>
<Alert alert={alert} />
<div className="container my-5">
<BrowserRouter>
<Routes>
<Route
path="/"
element={
<TextForm
showAlert={showAlert}
heading="Edit your text below"
/>
}
/>
<Route path="/about" element={<About />}/>
</Routes>
</BrowserRouter>
</div>
</>
);
} //end of App
export default App;