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
[ | |
{ | |
"location": "Abberton", | |
"population": "831" | |
}, | |
{ | |
"location": "Abbeytown", | |
"population": "819" | |
}, | |
{ |
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'; | |
// consumers | |
import { AlertConsumer } from './Alert'; // AlertContext.Consumer | |
import { UserConsumer } from './User'; //UserContext.Consumer | |
// -------------- CONTEXT FUNCTIONS -------------- // | |
// hoc for adding a context to a component as a consumer | |
const hocContextConsumer = function(ComposedComponent, ContextConsumer, name) { |
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"; | |
// delay a state change (used for loading or waiting for async to avoid flash of loading state) | |
export default function useDelay(initial, { delay = 300, delayedValue = true, minDuration = 700 }) { | |
const [state, setState] = React.useState(initial); | |
const [change, setChange] = React.useState(initial); | |
const end = React.useRef(0); | |
React.useEffect(() => { | |
let timer; |
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'; | |
// sub-components | |
import DragItem from './DragItem'; | |
import DropZone from './DropZone'; | |
import DropZones from './DropZones'; | |
import DropGuide from './DropGuide'; | |
// context for the drag | |
export const DragContext = React.createContext(); |