React Native Syntax Highlighter
Syntax highlighting component for React Native
using react-syntax-highlighter
You can try it out with Expo here
Install
npm install react-native-syntax-highlighter --save
Use
props
Accepts all of the same props as react-syntax-highlighter
with two additional props.
fontFamily
- the font family to use for syntax text.fontSize
- the fontSize for syntax text.
import SyntaxHighlighter from 'react-native-syntax-highlighter';
import { docco } from 'react-syntax-highlighter/dist/styles';
const Component = () => {
const codeString = '(num) => num + 1';
return <SyntaxHighlighter language='javascript' style={docco}>{codeString}</SyntaxHighlighter>;
}