Files
swagger-ui/src/core/components/highlight-code.jsx
2017-06-29 04:37:19 +02:00

30 lines
626 B
JavaScript

import React, { Component } from "react"
import PropTypes from "prop-types"
import { highlight } from "core/utils"
export default class HighlightCode extends Component {
static propTypes = {
value: PropTypes.string.isRequired,
className: PropTypes.string
}
componentDidMount() {
highlight(this.el)
}
componentDidUpdate() {
highlight(this.el)
}
initializeComponent = (c) => {
this.el = c
}
render () {
let { value, className } = this.props
className = className || ""
return <pre ref={this.initializeComponent} className={className + " microlight"}>{ value }</pre>
}
}