X Tutup
import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { Light as SyntaxHighlighter } from 'react-syntax-highlighter'; import js from 'react-syntax-highlighter/dist/languages/hljs/javascript'; import { getJS, getCurrent } from '../selectors'; import CodePreTag from './CodePreTag'; SyntaxHighlighter.registerLanguage('javascript', js); const Code = props => { const { js, current, style } = props; return ( {js === 'es5' && ( {current.codeES5} )} {js === 'es6' && ( {current.codeES6} )} ); }; Code.propTypes = { js: PropTypes.string.isRequired, current: PropTypes.object.isRequired, style: PropTypes.object.isRequired }; export default connect(state => ({ js: getJS(state), current: getCurrent(state) }))(Code);
X Tutup