-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
119 lines (115 loc) · 4.75 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import 'react-native-get-random-values';
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { SafeAreaView, StyleSheet, ScrollView, View, Text } from 'react-native';
import { v1 as uuidv1, v4 as uuidv4, v3 as uuidv3, v5 as uuidv5 } from 'uuid';
import { nanoid } from 'nanoid';
export default function App() {
const MY_NAMESPACE = '55238d15-c926-4598-b49d-cf4e913ba13c';
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView>
<ScrollView contentInsetAdjustmentBehavior="automatic" style={styles.scrollView}>
<View style={styles.body}>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>nanoid()</Text>
<Text style={styles.sectionDescription}>{nanoid()}</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>uuidv1()</Text>
<Text style={styles.sectionDescription}>{uuidv1()}</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>uuidv4()</Text>
<Text style={styles.sectionDescription}>{uuidv4()}</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>uuidv3() DNS</Text>
<Text style={styles.sectionDescription}>
... using predefined DNS namespace (for domain names)
</Text>
<Text style={styles.sectionDescription}>
{uuidv3('hello.example.com', uuidv3.DNS)}
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>uuidv3() URL</Text>
<Text style={styles.sectionDescription}>
... using predefined URL namespace (for, well, URLs)
</Text>
<Text style={styles.sectionDescription}>
{uuidv3('http://example.com/hello', uuidv3.URL)}
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>uuidv3() URL</Text>
<Text style={styles.sectionDescription}>
{uuidv3('http://example.com/hello', uuidv3.URL)}
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>uuidv3() MY_NAMESPACE</Text>
<Text style={styles.sectionDescription}>... using a custom namespace</Text>
<Text style={styles.sectionDescription}>
Note: Custom namespaces should be a UUID string specific to your application! E.g.
the one here was generated using this modules `uuid` CLI.
</Text>
<Text style={styles.sectionDescription}>{uuidv3('Hello, World!', MY_NAMESPACE)}</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>uuidv5() DNS</Text>
<Text style={styles.sectionDescription}>
... using predefined DNS namespace (for domain names)
</Text>
<Text style={styles.sectionDescription}>
{uuidv5('hello.example.com', uuidv5.DNS)}
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>uuidv5() URL</Text>
<Text style={styles.sectionDescription}>
... using predefined URL namespace (for, well, URLs)
</Text>
<Text style={styles.sectionDescription}>
{uuidv5('http://example.com/hello', uuidv5.URL)}
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>uuidv5() MY_NAMESPACE</Text>
<Text style={styles.sectionDescription}>... using a custom namespace</Text>
<Text style={styles.sectionDescription}>
Note: Custom namespaces should be a UUID string specific to your application! E.g.
the one here was generated using this modules `uuid` CLI.
</Text>
<Text style={styles.sectionDescription}>{uuidv5('Hello, World!', MY_NAMESPACE)}</Text>
</View>
</View>
</ScrollView>
</SafeAreaView>
</>
);
}
const styles = StyleSheet.create({
scrollView: {
backgroundColor: '#fff',
},
body: {
backgroundColor: '#fff',
},
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
color: '#000',
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
color: '#000',
},
});