async-storage: async-storage is not working after importing as '@react-native-comiunity/async-storage

if I import async storage from react-native it only works in ios but can’t import as react-native-community/async-storage.error is

Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(Unable to resolve module react-native-community/async-storage from /Users/conconsolutions1/Documents/projects/venture-trading-app/src/Screens/Login/LogInScreen.js: Module react-native-community/async-storage does not exist in the Haste module map

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

What version of Async Storage are you using?

Try starting packager with your transform caches cleared, with react-native start --clearCache

@Krizzu You are absolutely right. There is no new AsyncStoragePackage() there in my MainApplication.java (it worked before with only react-native link). I am using react native router flux which I believe is a wrapper around react navigation (not the wix one). Thanks for your help.

Hi @Krizzu

yes node_modules/@react-native-community/async-storage dir is available

Can you check if you have node_modules/@react-native-community/async-storage dir available?

Hi @Krizzu

yes I restarted the metro bundler.y code is simple

class LogInScreen extends Component { constructor(props){ super(props); this.state= { username: '', password: '', } } userInfo = {username: 'admin',password: 'admin'} _login = async() => { if(this.userInfo.username === this.state.username && this.userInfo.password === this.state.password){ await AsyncStorage.setItem('isLoggedIn', '1'); this.props.navigation.navigate('DashboardTab') } else { alert('wrong password') } } _logout = async() => { await AsyncStorage.clear(); this.props.navigation.navigate('Auth'); } render() { return ( <SafeAreaView style={{flex: 1, }}> <View style={{flex:1,justifyContent: 'center',}}> <MainInput onChangeText={(username)=>this.setState({username})} placeholder="Mobile Number"></MainInput> <MainInput onChangeText={(password)=> this.setState({password})} secureTextEntry={true} placeholder="Password"></MainInput> </View> <MainButtonColor onPress={this._login} style={{bottom: 0,position: 'absolute'}}>LOGIN</MainButtonColor> <Button title="logOut" onPress={this._logout}/> </SafeAreaView> ) } } export default LogInScreen;

Hi @MalinPramoditha ,

Did you follow getting started instructions ? Have you restarted Metro after installing new modules?