From 62162b9fd3ae892695e61ef80e7ebba3df1f82f4 Mon Sep 17 00:00:00 2001 From: Sergey Lebedev Date: Thu, 5 May 2022 20:54:02 +0300 Subject: [PATCH 1/2] hw2 --- src/App.js | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/src/App.js b/src/App.js index 65b81b4..8c78aa9 100644 --- a/src/App.js +++ b/src/App.js @@ -1,13 +1,43 @@ import './App.css'; -import Message from './Message'; +import React, {useEffect} from "react"; +import {useState} from "react"; function App() { - const myText = "Tasks from Lesson 1 complete"; + const[messageList, setMessageList] = useState([]); + const[author, setAuthor] = useState(""); + const[message, setMessage] = useState(""); +//comment + let idCounter = messageList.length; + + useEffect(() => { + if(messageList.length > 0) + setTimeout(() => alert("Message send"), 1500) + }, [messageList]); + return ( -
- +
+ <> + setAuthor(e.target.value)}/> +
+ setMessage(e.target.value)}/> +
+ + + {messageList.map((item) => +

Author: {item.author}
Say: {item.text}

+ )} + +
+ ); + } -export default App; \ No newline at end of file +export default App; From 9268e0f8d788a7811864ae5db5b77ad4cc531802 Mon Sep 17 00:00:00 2001 From: Sergey Lebedev Date: Tue, 10 May 2022 02:13:07 +0300 Subject: [PATCH 2/2] last update --- .idea/.gitignore | 5 +++++ .idea/inspectionProfiles/Project_Default.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/myfirstapp.iml | 12 ++++++++++++ .idea/vcs.xml | 6 ++++++ src/App.js | 6 +----- 6 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/myfirstapp.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..03d9549 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..5a53714 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/myfirstapp.iml b/.idea/myfirstapp.iml new file mode 100644 index 0000000..0c8867d --- /dev/null +++ b/.idea/myfirstapp.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/App.js b/src/App.js index 8c78aa9..b2ddd70 100644 --- a/src/App.js +++ b/src/App.js @@ -1,12 +1,10 @@ import './App.css'; -import React, {useEffect} from "react"; -import {useState} from "react"; +import React, {useEffect, useState} from "react"; function App() { const[messageList, setMessageList] = useState([]); const[author, setAuthor] = useState(""); const[message, setMessage] = useState(""); -//comment let idCounter = messageList.length; useEffect(() => { @@ -35,9 +33,7 @@ function App() {
- ); - } export default App;