Skip to content

Commit

Permalink
Removed semicolons added by prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Carnageous committed Jul 5, 2022
1 parent e5f27d6 commit aabaaad
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/auto-generating-selectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ import create, { StateCreator, State, StoreApi, UseStore } from 'zustand'

interface Selectors<StoreType> {
use: {
[key in keyof StoreType]: () => StoreType[key]
[key in keyof StoreType]: () => StoreType[key];
}
}

function createSelectors<StoreType extends State>(store: UseStore<StoreType>) {
;(store as any).use = {}
(store as any).use = {};

Object.keys(store.getState()).forEach((key) => {
const selector = (state: StoreType) => state[key as keyof StoreType]
;(store as any).use[key] = () => store(selector)
const selector = (state: StoreType) => state[key as keyof StoreType];

(store as any).use[key] = () => store(selector);
})

return store as UseStore<StoreType> & Selectors<StoreType>
Expand Down

0 comments on commit aabaaad

Please sign in to comment.