This file contains hidden or 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
function* fibonacciGenerator() { | |
const sequence = [0, 1]; | |
yield 0; | |
yield 1; | |
while (true) { | |
let i = sequence.length; | |
sequence[i] = sequence[i - 1] + sequence[i - 2]; |
This file contains hidden or 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 useSWR from 'swr' | |
import { useState } from 'react' | |
import request from 'graphql-request' | |
import _ from 'lodash' | |
// GraphQL fetcher for SWR hook | |
export const graphqlFetcher = (query, variables) => request('http://localhost:4000/api/graphql', query, variables) | |
export const useLazySWR = (query) => { | |
// We're going to use SWR conditional fetching, |
This file contains hidden or 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
// https://github.com/TheClosure/parallax-tutorial | |
import { useEffect, useState } from 'react'; | |
const useParallax = (speed = 0.5) => { | |
const [offsetY, setOffsetY] = useState(0); | |
const handleScroll = () => setOffsetY(window.pageYOffset); | |
useEffect(() => { | |
window.addEventListener('scroll', handleScroll); |