
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
react-native-user-defaults
Advanced tools
when you want to store some small ,insensitive and permanent information in your app
npm install react-native-user-defaults
Libraries
, then click Add Files...
, select node_modules -> react-native-user-defaults -> RCTUserDefaults.xcodeproj
Build Phases -> Link Binary... -> Add items -> libRCTUserDefaults.a
If you are not clear about the step 2 and 3, you can check react-native official doc , follow the step 1 and 2 in the official doc.
In objective-c and swift, you have to use specific method for specific type, like setObject
and stringForKey
. But in react-native, I believe that all you need is just set
and get
.
Every method supports callback
and promise
import userDefaults from 'react-native-user-defaults'
set({String}, {String, Number, Bool, Object, Array}, [,suiteName] [,callback])
Example:
userDefaults.set("key1", "valueIsString")
.then(data => console.log(data)) // Save success
userDefaults.set("key2", [1, true], "group.com.company.app", (err, data) => {
if(!err) console.log(data) // Save success
})
get({String} [,suiteName] [,callback])
Example:
userDefaults.get("key1")
.then(data => console.log(data)) // value for the key1
userDefaults.get("key2", "group.com.company.app", (err, data) => {
if(!err) console.log(data) // value for the key2
})
remove({String} [,suiteName] [,callback])
Example:
userDefaults.remove("key1")
.then(data => console.log(data)) // Remove success
empty([suiteName] [,callback])
Example:
userDefaults.empty()
.then(data => console.log(data)) // Empty success
set('key1', '12')
, then get('key1')
, you will get 12
, not '12'
, I don't take this as a bug so that we can use this component more conveniently. If you don't think so, tell me.MIT
FAQs
ios UserDefaults used by react-native
The npm package react-native-user-defaults receives a total of 2,488 weekly downloads. As such, react-native-user-defaults popularity was classified as popular.
We found that react-native-user-defaults demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.