feat(client): ts-migrate .../Challenges/components/PrismFormatted.js (#42667)
* migrate * add mistakenly deleted displayName * add static displayName declaration * remove extra space Co-authored-by: Parth Parth <thecodingaviator@users.noreply.github.com> Co-authored-by: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com>
This commit is contained in:
6
client/package-lock.json
generated
6
client/package-lock.json
generated
@ -4110,6 +4110,12 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-5.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-5.0.3.tgz",
|
||||||
"integrity": "sha512-kUNnecmtkunAoQ3CnjmMkzNU/gtxG8guhi+Fk2U/kOpIKjIMKnXGp4IJCgQJrXSgMsWYimYG4TGjz/UzbGEBTw=="
|
"integrity": "sha512-kUNnecmtkunAoQ3CnjmMkzNU/gtxG8guhi+Fk2U/kOpIKjIMKnXGp4IJCgQJrXSgMsWYimYG4TGjz/UzbGEBTw=="
|
||||||
},
|
},
|
||||||
|
"@types/prismjs": {
|
||||||
|
"version": "1.16.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/prismjs/-/prismjs-1.16.5.tgz",
|
||||||
|
"integrity": "sha512-nSU7U6FQDJJCraFNwaHmH5YDsd/VA9rTnJ7B7AGFdn+m+VSt3FjLWN7+AbqxZ67dbFazqtrDFUto3HK4ljrHIg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/prop-types": {
|
"@types/prop-types": {
|
||||||
"version": "15.7.3",
|
"version": "15.7.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz",
|
||||||
|
@ -135,6 +135,7 @@
|
|||||||
"@types/jest": "26.0.23",
|
"@types/jest": "26.0.23",
|
||||||
"@types/loadable__component": "5.13.3",
|
"@types/loadable__component": "5.13.3",
|
||||||
"@types/lodash-es": "4.17.4",
|
"@types/lodash-es": "4.17.4",
|
||||||
|
"@types/prismjs": "^1.16.5",
|
||||||
"@types/react-dom": "17.0.8",
|
"@types/react-dom": "17.0.8",
|
||||||
"@types/react-helmet": "6.1.1",
|
"@types/react-helmet": "6.1.1",
|
||||||
"@types/react-instantsearch-dom": "6.10.1",
|
"@types/react-instantsearch-dom": "6.10.1",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React, { Fragment } from 'react';
|
import React, { Fragment } from 'react';
|
||||||
|
|
||||||
import PrismFormatted from './PrismFormatted';
|
import PrismFormatted from './prism-formatted';
|
||||||
import './challenge-description.css';
|
import './challenge-description.css';
|
||||||
|
|
||||||
type Challenge = {
|
type Challenge = {
|
||||||
|
@ -1,26 +1,27 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import Prism from 'prismjs';
|
import Prism from 'prismjs';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
const propTypes = {
|
interface PrismFormattedProps {
|
||||||
className: PropTypes.string,
|
className?: string;
|
||||||
text: PropTypes.string.isRequired
|
text: string;
|
||||||
};
|
}
|
||||||
|
|
||||||
class PrismFormatted extends Component {
|
class PrismFormatted extends Component<PrismFormattedProps> {
|
||||||
componentDidMount() {
|
static displayName: string;
|
||||||
|
instructionsRef: React.RefObject<HTMLInputElement>;
|
||||||
|
componentDidMount(): void {
|
||||||
// Just in case 'current' has not been created, though it should have been.
|
// Just in case 'current' has not been created, though it should have been.
|
||||||
if (this.instructionsRef.current) {
|
if (this.instructionsRef.current) {
|
||||||
Prism.highlightAllUnder(this.instructionsRef.current);
|
Prism.highlightAllUnder(this.instructionsRef.current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props: PrismFormattedProps | Readonly<PrismFormattedProps>) {
|
||||||
super(props);
|
super(props);
|
||||||
this.instructionsRef = React.createRef();
|
this.instructionsRef = React.createRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render(): JSX.Element {
|
||||||
const { text, className } = this.props;
|
const { text, className } = this.props;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -33,6 +34,5 @@ class PrismFormatted extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PrismFormatted.displayName = 'PrismFormatted';
|
PrismFormatted.displayName = 'PrismFormatted';
|
||||||
PrismFormatted.propTypes = propTypes;
|
|
||||||
|
|
||||||
export default PrismFormatted;
|
export default PrismFormatted;
|
@ -12,7 +12,7 @@ import { withTranslation } from 'react-i18next';
|
|||||||
import type { Dispatch } from 'redux';
|
import type { Dispatch } from 'redux';
|
||||||
|
|
||||||
// Local Utilities
|
// Local Utilities
|
||||||
import PrismFormatted from '../components/PrismFormatted';
|
import PrismFormatted from '../components/prism-formatted';
|
||||||
import {
|
import {
|
||||||
ChallengeNodeType,
|
ChallengeNodeType,
|
||||||
ChallengeMetaType
|
ChallengeMetaType
|
||||||
|
Reference in New Issue
Block a user