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
    
  
  
    
  | from hashlib import sha256 | |
| import json | |
| import time | |
| class Chain: | |
| def __init__(self): | |
| self.blockchain = [] | |
| self.pending = [] | |
| self.add_block(prevHash="Genesis", proof=123) | 
  
    
      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 useAutoScroll(ref) { | |
| useEffect(() => { | |
| const node = ref.current; | |
| node.scrollTop = node.scrollHeight; | |
| }); | |
| } | 
  
    
      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 useAuth() { | |
| const [user, setUser] = useState(null); | |
| useEffect(() => { | |
| return firebase.auth().onAuthStateChanged((user) => { | |
| if (user) { | |
| setUser({ | |
| displayName: user.displayName, | |
| photoUrl: user.photoURL, | |
| uid: user.uid, | 
  
    
      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 useCollection(path, orderBy) { | |
| const [docs, setDocs] = useState([]); | |
| useEffect(() => { | |
| return db | |
| .collection(path) | |
| .orderBy(orderBy) | |
| .onSnapshot((snapshot) => { | |
| const docs = []; | |
| snapshot.forEach((doc) => { | 
  
    
      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 React from "react" | |
| import FeedPost from "app/FeedPost" | |
| import { loadFeedPosts, subscribeToNewFeedPosts } from "app/utils" | |
| export default Feed | |
| const PER_PAGE = 3; | |
| function Feed() { | 
  
    
      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
    
  
  
    
  | /** | |
| * Logs a warning in dev mode when a component switches from controlled to | |
| * uncontrolled, or vice versa | |
| * | |
| * A single prop should typically be used to determine whether or not a | |
| * component is controlled or not. | |
| * | |
| * @param controlPropValue | |
| * @param controlPropName | |
| * @param componentName | 
  
    
      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
    
  
  
    
  | // Property of @dan_abramov. Very helpfull explanation of the mental model to change imperative APIs to more | |
| // declarative custom hooks. | |
| import React, { useState, useEffect, useRef } from 'react'; | |
| function useInterval(callback, delay) { | |
| const savedCallback = useRef(); | |
| // Remember the latest callback. | |
| useEffect(() => { | 
  
    
      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 React from 'react' | |
| function useSafeContext(customContext) { | |
| const context = React.useContext(customContext) | |
| if (!context) { | |
| throw new Error('You must use this context consumer hook inside a Provider') | |
| } | |
| return context | |
| } | 
  
    
      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 * as React from 'react' | |
| function useSafeDispatch(dispatch) { | |
| const mounted = React.useRef(false) | |
| React.useLayoutEffect(() => { | |
| mounted.current = true | |
| return () => { | |
| mounted.current = false | |
| } | 
  
    
      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 * as React from 'react' | |
| /** | |
| * | |
| * @param {String} key The key to set in localStorage for this value | |
| * @param {Object} defaultValue The value to use if it is not already in localStorage | |
| * @param {{serialize: Function, deserialize: Function}} options The serialize and deserialize functions to use (defaults to JSON.stringify and JSON.parse respectively) | |
| */ | |
| function useLocalStorageState( |