Files
freeCodeCamp/packages/learn/src/templates/Challenges/views/components/Output.js

33 lines
653 B
JavaScript
Raw Normal View History

2018-04-06 14:51:52 +01:00
import React from 'react';
import PropTypes from 'prop-types';
import { Controlled as CodeMirror } from 'react-codemirror2';
import './output.css';
const defaultOptions = {
lineNumbers: false,
lineWrapping: true,
mode: 'javascript',
readOnly: 'nocursor'
};
const propTypes = {
defaultOutput: PropTypes.string,
output: PropTypes.string
};
function Output({ output, defaultOutput }) {
return (
<CodeMirror
className='challenge-log'
options={{ ...defaultOptions, theme: 'material' }}
value={output || defaultOutput}
/>
);
}
Output.displayName = 'Output';
Output.propTypes = propTypes;
export default Output;