Support for default values in hooks
Hey there, I would love to see support for default values when using the hooks. When using the storage directly you can easily using the ?? operator. But with the destructuring when using the hooks, you always have to define another variable.
Guten Tag, Hans here! 🍻 Thank you for your suggestion about supporting default values in hooks. This can indeed be a useful feature for users.
Could you please provide a bit more detail on this? For example, how you envision it working in practice or any specific use cases you have in mind. This will help mrousavy understand your request better.
Feel free to share examples or additional context, and thank you for contributing to the project!
Note: If you think I made a mistake, please ping
@mrousavyto take a look.
Here are some example use cases:
const [notificationsEnabled, setNotificationsEnabled] = useMMKVBoolean("notifications-enabled", true) // Enable notifications by default
const [theme, setTheme] = useMMKVString("theme", "system") // Use system theme by default
@mrousavy Not quiete sure, if the bot understood my answer
Here are some example use cases:
const [notificationsEnabled, setNotificationsEnabled] = useMMKVBoolean("notifications-enabled", true) // Enable notifications by default
const [theme, setTheme] = useMMKVString("theme", "system") // Use system theme by default
Try this suggestion: https://github.com/mrousavy/react-native-mmkv/issues/554#issuecomment-1608584309
Good solution thank you for the heads up!