Solution#15
Open
MrHunterBoi wants to merge 2 commits into
Open
Conversation
ArtemTeslenko
suggested changes
Jan 15, 2024
ArtemTeslenko
left a comment
There was a problem hiding this comment.
Good job 👍 User should get some information about errors, please handle errors)
| try { | ||
| return axios.get(`${API_URL}/rooms`); | ||
| } catch (err) { | ||
| return []; |
There was a problem hiding this comment.
when the result of request is not successful you need to inform user about it, return empty array is not good
| try { | ||
| return axios.get(`${API_URL}/rooms/${id}`); | ||
| } catch (err) { | ||
| return []; |
There was a problem hiding this comment.
the same, check all over the document
| import './Chat.css'; | ||
| import { socket } from '../../webSocket.js'; | ||
|
|
||
| <h1 className="title">Chat application</h1>; |
Comment on lines
+13
to
+14
| const [rooms, setRooms] = useState([]); | ||
| const [room, setRoom] = useState(null); |
There was a problem hiding this comment.
it is not a mistake, but it decreases readability, try to avoid using similar names with a difference in one letter (room, rooms, etc.)
|
|
||
| export const MessageList = ({ messages }) => ( | ||
| <ul className="messageList"> | ||
| {messages.map(message => ( |
|
|
||
| setRooms(currentRooms => currentRooms.filter(currentRoom => currentRoom.id !== room.id)); | ||
| } catch (err) { | ||
| console.log(err); |
| try { | ||
| updateRoom(room.id, room.name); | ||
| } catch (err) { | ||
| console.log(err); |
Comment on lines
+6
to
+16
| // { | ||
| // id: '1', | ||
| // name: `Room #1`, | ||
| // messages: [ | ||
| // { | ||
| // time: new Date(), | ||
| // text: 'Ye', | ||
| // author: 'Max', | ||
| // }, | ||
| // ], | ||
| // }, |
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.