Added GroupProvider
This commit is contained in:
@@ -21,7 +21,7 @@ export function useLocalStorage<T>(key: string, initialValue: T): [T, SetValue<T
|
||||
// Get from local storage then
|
||||
// parse stored json or return initialValue
|
||||
const readValue = useCallback((): T => {
|
||||
// Prevent build error "window is undefined" but keep keep working
|
||||
// Prevent build error "window is undefined" but keep working
|
||||
if (typeof window === 'undefined') {
|
||||
return initialValue
|
||||
}
|
||||
@@ -88,7 +88,9 @@ export function useLocalStorage<T>(key: string, initialValue: T): [T, SetValue<T
|
||||
// See: useLocalStorage()
|
||||
useEventListener('local-storage', handleStorageChange)
|
||||
|
||||
return [storedValue, setValue]
|
||||
const [clientStoredValue, setClientStoredValue] = useState<T>(initialValue)
|
||||
useEffect(() => setClientStoredValue(storedValue), [storedValue])
|
||||
return [clientStoredValue, setValue]
|
||||
}
|
||||
|
||||
// A wrapper for "JSON.parse()"" to support "undefined" value
|
||||
|
||||
12
src/types.ts
12
src/types.ts
@@ -14,10 +14,20 @@ export interface Entity extends UnfetchedEntity {
|
||||
recipe?: Recipe
|
||||
}
|
||||
|
||||
export interface Group {
|
||||
export type Group = OldGroup|NewGroup
|
||||
|
||||
export interface OldGroup {
|
||||
name: string
|
||||
isExported?: boolean
|
||||
factories: string[]
|
||||
intermediates: string[]
|
||||
inputs: string[]
|
||||
}
|
||||
|
||||
export interface NewGroup {
|
||||
name: string
|
||||
inputs: string[]
|
||||
intermediates: string[]
|
||||
exports: string[]
|
||||
malls: string[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user