Skip to content

Instantly share code, notes, and snippets.

View RachelElysia's full-sized avatar
😵‍💫
2 under 2

RachelElysia

😵‍💫
2 under 2
View GitHub Profile
@RachelElysia
RachelElysia / favoritebutton.js
Created February 26, 2021 23:43
Favorite Button Component
"use strict";
import styles from '../styles/Home.module.css';
import React, { useState, useEffect } from 'react';
import useSWR from 'swr'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faHeart, faHeartBroken } from '@fortawesome/free-solid-svg-icons'
// Separate all fetches because render hooks has an issue with rendering
// hooks a different amount of times in the same component
@RachelElysia
RachelElysia / gist:c34bc386b9e3a603d29ef4890018027d
Created February 26, 2021 23:42
Favorite Button Component (/components/favoritebutton.js)
"use strict";
import styles from '../styles/Home.module.css';
import React, { useState, useEffect } from 'react';
import useSWR from 'swr'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faHeart, faHeartBroken } from '@fortawesome/free-solid-svg-icons'
// Separate all fetches because render hooks has an issue with rendering
// hooks a different amount of times in the same component