Skip to content

Commit e51ef8c

Browse files
committed
adding working example app
1 parent ae57527 commit e51ef8c

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

example/App.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import React, { Component } from 'react';
7-
import {Platform, Picker, ScrollView, StyleSheet, Text, View} from "react-native";
7+
import {Platform, Picker, ScrollView, StyleSheet, Text, View, Alert} from "react-native";
88

99
import Markdown, {
1010
AstRenderer,
@@ -25,6 +25,36 @@ const instructions = Platform.select({
2525
android: 'Double tap R on your keyboard to reload,\n' + 'Shake or press menu button for dev menu',
2626
});
2727

28+
const rules = {
29+
// added custom block element defined by plugin
30+
block: (node, children, parents, style) => {
31+
return (
32+
<Text key={getUniqueID()} style={{ backgroundColor: "green" }}>
33+
{children}
34+
</Text>
35+
);
36+
},
37+
38+
checkbox: (node, children, parents, style) => {
39+
return (
40+
<Text key={getUniqueID()} style={{ backgroundColor: "green" }}>
41+
{children}
42+
</Text>
43+
);
44+
}
45+
};
46+
47+
/**
48+
* i'm overriding the default h1 render function.
49+
*/
50+
const renderer = new AstRenderer(
51+
{
52+
...renderRules,
53+
...rules
54+
},
55+
styles
56+
);
57+
2858
export default class App extends Component {
2959
state = {
3060
view: 5,
@@ -74,6 +104,8 @@ export default class App extends Component {
74104
}
75105

76106
render() {
107+
console.log(this.state.view);
108+
77109
return (
78110
<View style={styleSheet.container}>
79111
<Picker

0 commit comments

Comments
 (0)