Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
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 1,212 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.