1import { Just, Nothing } from 'folktale/maybe';
2import Result from 'folktale/result';
3import React, { createContext, forwardRef, useContext } from 'react';
4import { noop } from 'lodash';
6import useDeepEqualReference from 'lib/useDeepEqualReference';
7import usePointStore from './lib/usePointStore';
10 * Avoid race condition by setting an initial dummy state. Previously, on
11 * occasion the application would render before the points queries finished
12 * loading data asynchronously from the roller and Infura. This would cause
13 * a crash in Points.tsx when attempting to destructure the data.
15const initialContext = {
17 rekeyDates: Nothing(),
18 controlledPoints: Nothing(),
21 pointCursor: Nothing(),
23 syncEclipticOwner:noop,
25 syncControlledPoints: noop,
31export const PointCacheContext = createContext(initialContext);
33export function PointCacheProvider({ children }) {
34 const cache = usePointStore();
37 <PointCacheContext.Provider value={useDeepEqualReference(cache)}>
39 </PointCacheContext.Provider>
44export function usePointCache() {
45 return useContext(PointCacheContext);
49export const withPointCache = Component =>
50 forwardRef((props, ref) => (
51 <PointCacheContext.Consumer>
52 {cache => <Component ref={ref} {...cache} {...props} />}
53 </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