This file contains 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
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'} /> |
This file contains 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
const parseQuery = new Parse.Query('Post'); | |
parseQuery.descending("createdAt"); |
This file contains 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
import {useEffect, useState } from 'react' | |
import {useHistory} from 'react-router-dom'; | |
import Parse from 'parse'; | |
import './Home.css' | |
import {useParseQuery} from '@parse/react'; | |
export default function Home() { | |
const [postText, setPostText] = useState(''); | |
const history = useHistory(); |
This file contains 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
const handleSubmitPost = (e) => { | |
e.preventDefault(); | |
const Post = Parse.Object.extend("Post"); | |
const newPost = new Post(); | |
newPost.save({ | |
text: postText, | |
authorName: Parse.User.current().get('username'), | |
}); | |
setPostText(""); | |
}; |
This file contains 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
import {useEffect, useState } from 'react' | |
import {useHistory} from 'react-router-dom'; | |
import Parse from 'parse'; | |
import './Home.css' | |
import {useParseQuery} from '@parse/react'; | |
export default function Home() { | |
const [postText, setPostText] = useState(''); | |
const history = useHistory(); |
This file contains 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
{results && results.map((user,index) => ( | |
<div className="post" key={index}> | |
<span>{user.get('authorName')}</span> | |
<p>{user.get('text')}</p> | |
</div>))} |
This file contains 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
const { | |
isLive, | |
isLoading, | |
isSyncing, | |
results, | |
count, | |
error, | |
reload | |
} = useParseQuery( | |
parseQuery |
This file contains 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
import {useEffect } from 'react' | |
import {useHistory} from 'react-router-dom'; | |
import Parse from 'parse'; | |
import './Home.css' | |
import {useParseQuery} from '@parse/react'; | |
export default function Home() { | |
const history = useHistory(); |
This file contains 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
import {useEffect } from 'react' | |
import {useHistory} from 'react-router-dom'; | |
import Parse from 'parse'; | |
import './Home.css' | |
export default function Home() { | |
const initialPosts = [{ | |
userName: 'User 1', | |
post: "Hi, I'm a placeholder" |
This file contains 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
const handleRegister = () => { | |
const user = new Parse.User(); | |
user.set('username', userName); | |
user.set('password', password); | |
user.signUp().then(() => { | |
handleLogin(); | |
}).catch(err => alert(err.message)); | |
}; |
NewerOlder