Created
February 2, 2019 17:43
-
-
Save abranhe/4b538f65e452089b9c1cbda36ce09310 to your computer and use it in GitHub Desktop.
React Native Syntax Highlighter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { StyleSheet, Text, View, TextInput } from 'react-native'; | |
import { Ionicons } from '@expo/vector-icons'; | |
import SyntaxHighlighter from 'react-native-syntax-highlighter'; // 2.0.0 | |
import { tomorrow } from 'react-syntax-highlighter/styles/prism' // 7.0.1 | |
const code = `const example = require('example'); | |
console.log('Some example ' + example()); | |
`; | |
class CodeEditor extends Component { | |
constructor() { | |
super(); | |
this.state = { code }; | |
} | |
render() { | |
return ( | |
<View style={{ backgroundColor: '#E87A90', height: '100%'}}> | |
<Text style={{ marginTop: 30, marginBottom: 30, textAlign: 'center', fontSize: 22, fontWeight: '900' }}>React Native Syntax Higlighter</Text> | |
<SyntaxHighlighter | |
{...this.props} | |
style={tomorrow} | |
customStyle={{padding: 0, margin: 0 }} | |
language='javascript' | |
fontSize={18} | |
highlighter="prism" | |
> | |
{this.state.code} | |
</SyntaxHighlighter> | |
</View> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment