[ABANDONED] React/Redux front end for the Flexor social network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

14 lines
454 B

import { denormalize } from 'src/utils/normalization'
import { AppState, Entity, EntityType } from '../types'
export const getEntityStore = (state: AppState) => state.entities
export const getEntity = <T extends Entity = Entity>(state: AppState, type: EntityType, id?: string) => {
if (!id) return
const entities = getEntityStore(state)
switch (type) {
default:
return denormalize([id], type, entities)[0] as T
}
}