Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Aug 26, 2023
1 parent f26af60 commit 262256f
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,18 @@ import {
TouchableOpacity,
View,
} from 'react-native';
// @ts-expect-error
import MMKVStorage, {create} from 'react-native-mmkv-storage';
import {MMKVLoader, create} from 'react-native-mmkv-storage';

const Button = ({title, onPress}: {title: string; onPress: () => void}) => {
return (
<TouchableOpacity style={styles.button} onPress={onPress}>
<Text style={{color: 'white'}}>{title}</Text>
</TouchableOpacity>
);
};
const storage = new MMKVLoader().withEncryption().initialize();

const storage2 = new MMKVLoader().withInstanceID('storage2').initialize();

const storage = new MMKVStorage.Loader().withEncryption().initialize();
const useStorage = create(storage);
const useStorage2 = create(storage2);

const App = () => {
const [user, setUser] = useStorage('user', 'robert');
const [age, setAge] = useStorage('age', 24);
const [age, setAge] = useStorage2('age', 24);

const getUser = useCallback(() => {
let users = ['andrew', 'robert', 'jack', 'alison'];
Expand Down Expand Up @@ -91,6 +86,14 @@ const App = () => {
);
};

const Button = ({title, onPress}: {title: string; onPress: () => void}) => {
return (
<TouchableOpacity style={styles.button} onPress={onPress}>
<Text style={{color: 'white'}}>{title}</Text>
</TouchableOpacity>
);
};

export default App;

const styles = StyleSheet.create({
Expand Down

1 comment on commit 262256f

@vercel
Copy link

@vercel vercel bot commented on 262256f Aug 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

rnmmkv – ./

rnmmkv-git-master-ammarahm-ed.vercel.app
rnmmkv.vercel.app
rnmmkv-ammarahm-ed.vercel.app

Please sign in to comment.