react-native-mmkv-storage icon indicating copy to clipboard operation
react-native-mmkv-storage copied to clipboard

Using TypeScript the docs don´t work

Open ViniDevBR opened this issue 2 years ago • 1 comments

Describe the bug Just giving a copy and paste in the code in the cods using the hook useMMKVStorage() 1° - const MMKV: MMKVStorage.API = new MMKVLoader().initialize() TS say: 'MMKVStorage' refers to a value, but is being used as a type here. Did you mean 'typeof MMKVStorage' but using typeof MMKVStorage.API this returns error 2° - const [value, setValue] = useStorage(' ') - When i press CTRL+SPACE, to see the options, this returns nothing

Hacks When i just use ----> key: 'clientList' | 'totalDay' | 'totalMonth' ------ Without the LiteralUnion the TS returns my 3 options

Screenshots image

THIS WORKS image image

FIX Doing this, will work, but keeping the (U =string), if i put any string inside my hook this wont send error because U accepts string too. image

Platform Information:

  • OS: [e.g. iOS/Android]
  • React Native Version [e.g. 0.64]
  • Library Version [e.g. 0.8]

ViniDevBR avatar Jan 05 '23 15:01 ViniDevBR

For issue the first issue MMKVLoader().initialize() returns type MMKVInstance

Mookiies avatar Jul 06 '23 11:07 Mookiies