-
-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: What is the difference between react-native-mmkv & react-native-mmkv-storage ? #301
Comments
Duplicate of #100 Using the search function isn't that hard :) |
As @hirbod said, I explained the differences in detail here: #100 (comment) |
Hey, I have read the comparison section , I am really hesitant at this point, one thing that got my attention is that everything is synchronous in this library, does this make a difference ? |
Well yes, it does. FasterIt's faster than a Bridge call. By magnitudes. Like, really really fast. Easy accessConsider the following code: const isLoggedIn = storage.getBoolean('is-logged-in')
function App() {
return isLoggedIn ? <Main /> : <Login />
} This is fast, shows the correct UI (Main or Login) immediately, and does not cause any re-renders. This is how it works with my library. Let's try to build the same UI with an asynchronous storage: function App() {
const [isLoggedIn, setIsLoggedIn] = useState(false)
const [isLoading, setIsLoading] = useState(true)
useEffect(() => {
(async () => {
const data = await storage.getBooleanAsync('is-logged-in')
setIsLoggedIn(data)
setIsLoading(false)
})()
}, [])
if (isLoading) return <Loading />
return isLoggedIn ? <Main /> : <Login />
} Also note that there is a downside with a synchronous API: When storing huge amounts of data, it is better to use an actual database like WatermelonDB or SQLite since MMKV is in-memory. |
Well, thank you for this part, I can see a big difference now, last thing I want to ask about is encryption, we are creating a password manager app where we need to store some secret key for local login usage, is the encryption reliable for this case? I did not really get how it works from docs, is it handled by the library or do I need to create my own keys ? |
Okay, thank you, Does the data storage remain in the phone after uninstalling the app, or does it get deleted automatically? I hope that everything would be deleted? If not, what is the solution for this? |
Everything will be deleted when the user uninstalls your app. |
Can I encrypt without providing a key? Or do I always need to provide a key. I'm a bit new to this but I'm comparing this to SecureStore (with expo). SecureStore mentions it uses Keychain for iOS at least. I'm guessing this doesn't use keychain or anything like that correct? |
I am wondering why do we have two libraries doing the same job, which one shall I use ?
The text was updated successfully, but these errors were encountered: