Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
name,
age,
traits: {trait1, trait2},
} = this.state;
const obj = {
name,
age,
traits: {
trait1,
trait2,
},
};
try {
await AsyncStorage.mergeItem(KEY, JSON.stringify(obj));
} catch (e) {
console.warn(e);
}
this.setState({needRestart: true});
};
mergeItem: key => AsyncStorage.mergeItem(key),
flushGetRequests: () => AsyncStorage.flushGetRequests(),