Skip to content

Commit c210a08

Browse files
committed
updated example
1 parent 049d043 commit c210a08

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

example/App.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
TouchableOpacity,
88
View,
99
} from 'react-native';
10-
import MMKVStorage, {useMMKVStorage} from 'react-native-mmkv-storage';
10+
import MMKVStorage, {create} from 'react-native-mmkv-storage';
1111

1212
const Button = ({title, onPress}) => {
1313
return (
@@ -18,15 +18,14 @@ const Button = ({title, onPress}) => {
1818
};
1919

2020
const storage = new MMKVStorage.Loader().withEncryption().initialize();
21-
const useStorage = key => {
22-
const [value, setValue] = useMMKVStorage(key, storage);
23-
return [value, setValue];
24-
};
21+
const useStorage = create(storage);
22+
2523
const App = () => {
2624
const [user, setUser] = useStorage('user');
2725
const [age, setAge] = useStorage('age');
2826

2927
const getUser = useCallback(() => {
28+
3029
let users = ['andrew', 'robert', 'jack', 'alison'];
3130
let _user =
3231
users[

0 commit comments

Comments
 (0)