Skip to content

Instantly share code, notes, and snippets.

View josuerodcat90's full-sized avatar
👨‍💻
Never Stop Learning

Josue Rodriguez josuerodcat90

👨‍💻
Never Stop Learning
View GitHub Profile
import React, { useState, useEffect } from 'react';
import Welcome from '../Components/Welcome';
import ExcerciseList from '../Components/ExcerciseList';
import AddButton from '../Components/AddButton';
const Exercises = props => {
const [state, setState] = useState({
data: []
});
//this code snippet solve the problem with frontend refresh when you write the cache with PostForm:
//in Home.js use this:
const [posts, setPosts] = useState([]);
const { user } = useContext(AuthContext);
const { loading, data } = useQuery(FETCH_POSTS_QUERY);
useEffect(() => {
if (data) {
setPosts(data.getPosts);
}