Skip to content

Instantly share code, notes, and snippets.

View gabrielEloy's full-sized avatar

Gabriel Eloy gabrielEloy

  • Quest Mindshare
  • Curitiba, Brazil
View GitHub Profile
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'} />
const parseQuery = new Parse.Query('Post');
parseQuery.descending("createdAt");
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();
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("");
};
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();
{results && results.map((user,index) => (
<div className="post" key={index}>
<span>{user.get('authorName')}</span>
<p>{user.get('text')}</p>
</div>))}
const {
isLive,
isLoading,
isSyncing,
results,
count,
error,
reload
} = useParseQuery(
parseQuery
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();
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"
const handleRegister = () => {
const user = new Parse.User();
user.set('username', userName);
user.set('password', password);
user.signUp().then(() => {
handleLogin();
}).catch(err => alert(err.message));
};