Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Working from home

gabrielEloy

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