Webatrice: KnownHosts component (#4456)

* refactor dexie services for future schema updates

Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
This commit is contained in:
Jeremy Letto 2021-11-25 21:12:23 -06:00 committed by GitHub
parent 37879c4255
commit 6ce346af4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 1381 additions and 1291 deletions

View file

@ -6,8 +6,8 @@ File is adapted from https://github.com/Qeepsake/use-redux-effect under MIT Lice
import { useRef, useEffect, DependencyList } from 'react'
import { useStore } from 'react-redux'
import { castArray } from 'lodash'
import { AnyAction } from 'redux'
import { castArray } from 'lodash'
export type ReduxEffect = (action: AnyAction) => void
@ -23,25 +23,25 @@ export function useReduxEffect(
type: string | string[],
deps: DependencyList = [],
): void {
const currentValue = useRef(null)
const store = useStore()
const currentValue = useRef(null);
const store = useStore();
const handleChange = (): void => {
const state = store.getState()
const action = state.action
const previousValue = currentValue.current
currentValue.current = action.count
const state = store.getState();
const action = state.action;
const previousValue = currentValue.current;
currentValue.current = action.count;
if (
previousValue !== action.count &&
castArray(type).includes(action.type)
) {
effect(action)
effect(action);
}
}
useEffect(() => {
const unsubscribe = store.subscribe(handleChange)
return (): void => unsubscribe()
const unsubscribe = store.subscribe(handleChange);
return (): void => unsubscribe();
}, deps)
}