@reduxjs/toolkit
Version:
The official, opinionated, batteries-included toolset for efficient Redux development
19 lines (15 loc) • 542 B
text/typescript
import { IdSelector } from './models'
export function selectIdValue<T>(entity: T, selectId: IdSelector<T>) {
const key = selectId(entity)
if (process.env.NODE_ENV !== 'production' && key === undefined) {
console.warn(
'The entity passed to the `selectId` implementation returned undefined.',
'You should probably provide your own `selectId` implementation.',
'The entity that was passed:',
entity,
'The `selectId` implementation:',
selectId.toString()
)
}
return key
}