1import { Nothing } from 'folktale/maybe';
2import React, { createContext, forwardRef, useContext } from 'react';
3import { noop } from 'lodash';
5import useDeepEqualReference from 'lib/useDeepEqualReference';
6import usePointStore from './lib/usePointStore';
9 * Avoid race condition by setting an initial dummy state. Previously, on
10 * occasion the application would render before the points queries finished
11 * loading data asynchronously from the roller and Infura. This would cause
12 * a crash in Points.tsx when attempting to destructure the data.
14const initialContext = {
16 rekeyDates: Nothing(),
17 controlledPoints: Nothing(),
20 pointCursor: Nothing(),
22 syncEclipticOwner: noop,
24 syncControlledPoints: noop,
30export const PointCacheContext = createContext(initialContext);
32export function PointCacheProvider({ children }) {
33 const cache = usePointStore();
36 <PointCacheContext.Provider value={useDeepEqualReference(cache)}>
38 </PointCacheContext.Provider>
43export function usePointCache() {
44 return useContext(PointCacheContext);
48export const withPointCache = Component =>
49 forwardRef((props, ref) => (
50 <PointCacheContext.Consumer>
51 {cache => <Component ref={ref} {...cache} {...props} />}
52 </PointCacheContext.Consumer>
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list