Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import './App.css';
import chatMessages from './data/messages.json';
import ChatLog from './components/ChatLog.js';

const App = () => {
const likeCount = chatMessages.reduce((a, obj) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a clever use of reduce to count

return a + obj.liked;
}, 0);

const updateLikes = () => {
return 0;
};

return (
<div id="App">
<header>
<h1>Application title</h1>
<h2>{likeCount}'❤️'s</h2>
</header>
<main>{<ChatLog entries={chatMessages}></ChatLog>}</main>
<main>
{
<ChatLog
entries={chatMessages}
likeCount={likeCount}
updateLikes={updateLikes}
></ChatLog>
}
</main>
</div>
);
};
Expand Down