@@ -53,7 +53,123 @@ const App: () => React$Node = () => {
53
53
54
54
export default App ;
55
55
```
56
+ You can find this example [ here] ( https://snack.expo.dev/@hassieb/react-native-markdown-display-ordered-list )
56
57
58
+ This next example worked with ` "react-native-markdown-display": "^7.0.0-alpha.2", ` on React` 18.1.0 ` , React Native ` 0.70.5 ` via the Expo command ` npx create-expo-app --template ` with typescript selected.
59
+
60
+ ``` jsx
61
+ import React from " react" ;
62
+ import { StyleSheet , SafeAreaView , ScrollView , StatusBar } from " react-native" ;
63
+ import { useTheme } from " @react-navigation/native" ;
64
+
65
+ import Markdown from " react-native-markdown-display" ;
66
+
67
+ const copy = ` # h1 Heading 8-)
68
+
69
+ **This is some bold text!**
70
+
71
+ This is normal text
72
+ ` ;
73
+
74
+ const MarkdownWrapper: React .FC <any > = ({ children }) => {
75
+ const { colors } = useTheme ();
76
+ // @ts-ignore
77
+ return < Markdown style= {styles ({ colors })}> {children}< / Markdown> ;
78
+ };
79
+
80
+ const App: () = > React .ReactElement = () => {
81
+ return (
82
+ <>
83
+ < StatusBar barStyle= " dark-content" / >
84
+ < SafeAreaView>
85
+ < ScrollView
86
+ contentInsetAdjustmentBehavior= " automatic"
87
+ style= {{ height: " 100%" }}
88
+ >
89
+ < MarkdownWrapper> {copy}< / MarkdownWrapper>
90
+ < / ScrollView>
91
+ < / SafeAreaView>
92
+ < / >
93
+ );
94
+ };
95
+
96
+ export const styles = (props : any ) =>
97
+ StyleSheet .create ({
98
+ text: {
99
+ color: props .colors .text ,
100
+ },
101
+ });
102
+
103
+ export default App ;
104
+ ```
105
+
106
+ With text input
107
+
108
+ ``` jsx
109
+ import React from " react" ;
110
+ import {
111
+ StyleSheet ,
112
+ SafeAreaView ,
113
+ ScrollView ,
114
+ StatusBar ,
115
+ TextInput ,
116
+ } from " react-native" ;
117
+ import { useTheme } from " @react-navigation/native" ;
118
+
119
+ import Markdown from " react-native-markdown-display" ;
120
+
121
+ const copy = ` # h1 Heading 8-)
122
+
123
+ **This is some bold text!**
124
+
125
+ This is normal text
126
+ ` ;
127
+
128
+ const MarkdownWrapper: React .FC <any > = ({ children }) => {
129
+ const { colors } = useTheme ();
130
+ // @ts-ignore
131
+ return < Markdown style= {styles ({ colors })}> {children}< / Markdown> ;
132
+ };
133
+
134
+ const App: () = > React .ReactElement = () => {
135
+ const [text , onChangeText ] = React .useState (copy);
136
+ const { colors } = useTheme ();
137
+ return (
138
+ <>
139
+ < StatusBar barStyle= " dark-content" / >
140
+ < SafeAreaView>
141
+ < ScrollView
142
+ contentInsetAdjustmentBehavior= " automatic"
143
+ style= {{ height: " 100%" }}
144
+ >
145
+ < TextInput
146
+ multiline
147
+ style= {{ ... styles ({colors}).input , color: colors .text }}
148
+ onChangeText= {onChangeText}
149
+ value= {text}
150
+ / >
151
+ < MarkdownWrapper> {text}< / MarkdownWrapper>
152
+ < / ScrollView>
153
+ < / SafeAreaView>
154
+ < / >
155
+ );
156
+ };
157
+
158
+ export const styles = (props : any ) =>
159
+ StyleSheet .create ({
160
+ text: {
161
+ color: props .colors .text ,
162
+ },
163
+ input: {
164
+ height: 80 ,
165
+ margin: 12 ,
166
+ borderWidth: 1 ,
167
+ padding: 10 ,
168
+ },
169
+ });
170
+
171
+ export default App ;
172
+ ```
57
173
58
174
### Props and Functions
59
175
0 commit comments