Skip to content

Instantly share code, notes, and snippets.

@gabrielEloy
Created August 20, 2021 05:13
Show Gist options
  • Save gabrielEloy/ce885a25f63615c97543d1f6aa990159 to your computer and use it in GitHub Desktop.
Save gabrielEloy/ce885a25f63615c97543d1f6aa990159 to your computer and use it in GitHub Desktop.
const order = (posts) => {
return posts.sort((a, b) => {
return b.get("createdAt") - a.get("createdAt");
});
};
return (
<div className="App">
<header className="app-header">
<img className="logo" alt="back4app's logo" src={'https://blog.back4app.com/wp-content/uploads/2019/05/back4app-white-logo-500px.png'} />
<h2 className="spacing">parse hooks</h2>
<span>social network</span>
</header>
<div className="posts-container">
<form onSubmit={handleSubmitPost}className="actions">
<textarea value={postText} onChange={event => setPostText(event.currentTarget.value)}/>
<button type="submit">post</button>
</form>
<div className="post-list">
{results && order(results).map((user,index) => (
<div className="post" key={index}>
<span>{user.get('authorName')}</span>
<p>{user.get('text')}</p>
</div>))}
</div>
</div>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment