Toggle navigation
Toggle navigation
This project
Loading...
Sign in
황선혁
/
weather_chatbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Eric Whale
2022-05-31 21:05:46 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cb7c697b915ce66e7cfd8f233b3c348fba219b82
cb7c697b
1 parent
e07b1fc2
Setup chatroom page chatting room functionality
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
client/src/App.js
client/src/components/UserBox.jsx
client/src/App.js
View file @
cb7c697
import
axios
from
"axios"
;
import
{
useState
,
useEffect
}
from
"react"
;
// components
import
Bottombar
from
"./components/Bottombar"
;
import
Topbar
from
"./components/Topbar"
;
import
ChatroomBox
from
"./components/ChatroomBox"
;
function
App
()
{
const
[
chats
,
setChats
]
=
useState
(
null
);
useEffect
(()
=>
{
axios
.
get
(
"/api/chat"
).
then
((
response
)
=>
{
setChats
(
response
.
data
);
});
},
[]);
return
(
<
div
>
<
Topbar
/>
...
...
@@ -17,10 +27,13 @@ function App() {
<
br
/>
<
div
>
<
ChatroomBox
/>
<
ChatroomBox
/>
<
ChatroomBox
/>
<
ChatroomBox
/>
{
Array
.
isArray
(
chats
)
?
(
chats
.
map
((
chat
,
i
)
=>
{
return
<
ChatroomBox
key
=
{
i
}
chat
=
{
chat
}
/>
;
})
)
:
(
<
h2
>
No
chatting
room
!<
/h2
>
)}
<
/div
>
<
Bottombar
/>
<
/div
>
...
...
client/src/components/UserBox.jsx
View file @
cb7c697
...
...
@@ -5,7 +5,7 @@ function UserBox({ user }) {
<
div
className=
"userBox"
>
<
h1
>
{
user
.
username
}
</
h1
>
<
p
>
user info
</
p
>
<
div
>
chat!
</
div
>
<
div
>
chat!
(chatting functionality)
</
div
>
</
div
>
);
}
...
...
Please
register
or
login
to post a comment