astoilkov/use-local-storage-state

Additional type exports

paulmelnikow opened this issue · 4 comments

Hi there, and thanks for this great library! Have just upgraded from v6 to v15 and it seems to be working well.

Since createLocalStorageStateHook() has been removed and I was using it in one place, I replaced it with my own function, which I needed to annotate with my own types. I ended up checking this in:

export type UpdateState<T> = (newValue: T | ((value: T) => T)) => void
export type LocalStorageState<T> = [T, UpdateState<T>, LocalStorageProperties]
export interface LocalStorageProperties {
  isPersistent: boolean
  removeItem: () => void
}

Would you consider using / exporting these types from the package? I'd be happy to open a PR.

Great idea. Thanks! I will do it, no need for a PR. I will write you when I'm done.

Done. You can see the implementation and share your thoughts.

Wow, that looks great! And thanks so much! I look forward to giving it a try.

Great! I will make a new v16 release soon.