nurbol.dev

nurbol.dev

Pick helper

export function pick<T extends Record<string, unknown>, K extends keyof T>(
  obj: T,
  ...keys: Array<K>
): Pick<T, K> {
  let picked: Partial<T> = {};

  for (const key of keys) {
    picked[key] = obj[key];
  }

  return picked as Pick<T, K>;
}
const { keyOne, keyTwo } = useStore((state) => pick(state, 'keyOne', 'keyTwo'), shallow);