Type 'AsyncStorageStatic' is not assignable to type 'AsyncStorage'
Describe the bug
The typescript type definition of AsyncStorage as provided by @react-native-community/async-storage does not match the typescript type definition of the asyncStorage paramater to the getStorybookUI initialization function.
To Reproduce Steps to reproduce the behavior:
- Install
@react-native-community/async-storageand storybook in a react native expo project. - Configure storybook as such:
import AsyncStorage from '@react-native-community/async-storage';
configure(() => {
require('./stories'); // eslint-disable-line global-require
}, module);
const Storybook = getStorybookUI({
asyncStorage: AsyncStorage,
});
export default Storybook;
- There is a type error for the
asyncStorageparam.
Expected behavior
The parameter should accept the type of the recommended AsyncStorage by react-native, since the one imported from react-native is deprecated.
Screenshots

System:
Environment Info:
System:
OS: macOS 10.15.4
CPU: (4) x64 Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
Binaries:
Node: 12.18.1 - ~/.nvm/versions/node/v12.18.1/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.14.5 - ~/.nvm/versions/node/v12.18.1/bin/npm
Browsers:
Chrome: 85.0.4183.102
Firefox: 72.0.2
Safari: 13.1
npmPackages:
@storybook/react-native: ^5.3.19 => 5.3.21
@storybook/react-native-server: ^5.3.19 => 5.3.21
@Joshandrews43 Can you please include the line where you import AsyncStorage so I can see if you are using the default export.
@Joshandrews43 Can you please include the line where you import AsyncStorage so I can see if you are using the default export.
@dannyhw I've updated my code above to reflect this. I am indeed using the default export.
@Joshandrews43 I actually did a release of 5.3.23 pretty much just now, might be worth just quickly checking if it's resolved with the latest version since I did make a few changes related to typescript.
@react-native-community/async-storage is Deprecated.
devs migrated packages to @react-native-async-storage/async-storage.
@react-native-community/async-storageis Deprecated. devs migrated packages to@react-native-async-storage/async-storage.
Does that mean this is closed? I was searching the first issue tag..
This prop will no longer be required in 6.0 the @react-native-async-storage/async-storage package will become a dependency instead of being passed as a param.
I would suggest to revert this decision to bundle async-storage with this package. We removed async-storage from our app entirely and using react-mmkv which is much faster and easier to use cause its sync. To have the option to provide the means of persisting state is good software design so the current interface is just fine and I can easily adopt it to react-mmkv
However, there is slight problem:
asyncStorage: {
getItem(key) {
return Promise.resolve(mmkv.getStringSetting(key) || null);
}
setItem(key, value) {
return Promise.resolve(mmkv.setStringSetting(key, value));
}
}
does not work in 5.3.27. The StoryBookUI is not loading stories anymore. Setting the asyncStorage to null makes it work again, but of course no longer persists values.
@pke I'd be happy to take any PRs to make the storage solution optional (new features like this would go to v6 not 5.3). The reason for making it a requirement was just to simplify things.
Sure it could default to the optional dependency of asyncstorage but should be configurable. And believe me, once you tried synced settings you will not go back to async ones ;)
Closing since the async storage option isn't required anymore. A new issue should be made to make the local storage configurable