Reputation: 85
I am try to save integer variable to the AsyncStorage, however it return me the error
the bind value at index 1 is null
This is the code that i save item
AsyncStorage.setItem(
Common.CURRENT_CHILD,
this.state.child.toString(), //14
() => {
NavigationService.navigate('Home', {
childName: this.state.childName
});
}
);
This is the code that i retrieve item
AsyncStorage.getItem(Common.CURRENT_CHILD, (err, result) => {
if (result === null) {
console.log(err);
} else {
this.setState(
{
child: result
},
() => {
console.log('Result -', result);
}
);
}
})
Upvotes: 0
Views: 1667
Reputation: 154
AsyncStorage.setItem(
Common.CURRENT_CHILD,
""+ this.state.child.toString(), //14
() => {
NavigationService.navigate('Home', {
childName: this.state.childName
});
}
);
you can write "" while set item to Asyncstorage and try to use console.log while getting Item before if statement or
write
AsyncStorage.setItem(
Common.CURRENT_CHILD,
""+ this.state.child, //14
() => {
NavigationService.navigate('Home', {
childName: this.state.childName
});
}
);
Upvotes: 1