11import React from 'react' ;
2+ import ReactDOM from 'react-dom' ;
23import PropTypes from 'prop-types' ;
34import { withStyles } from '@material-ui/core/styles' ;
45import { choiceUtils as utils } from '@pie-lib/pie-toolbox/config-ui' ;
@@ -16,6 +17,7 @@ import Category from './category';
1617import Header from '../header' ;
1718import { generateValidationMessage , getMaxCategoryChoices } from '../../utils' ;
1819import { RowLabel } from './RowLabel' ;
20+ import { renderMath } from '@pie-lib/pie-toolbox/math-rendering' ;
1921
2022const styles = ( theme ) => ( {
2123 categories : {
@@ -79,6 +81,30 @@ export class Categories extends React.Component {
7981 focusedEl : null ,
8082 } ;
8183
84+ componentDidMount ( ) {
85+ try {
86+ // eslint-disable-next-line react/no-find-dom-node
87+ const domNode = ReactDOM . findDOMNode ( this ) ;
88+
89+ renderMath ( domNode ) ;
90+ } catch ( e ) {
91+ // Added try-catch block to handle "Unable to find node on an unmounted component" error from tests, thrown because of the usage of shallow
92+ console . error ( 'DOM not mounted' ) ;
93+ }
94+ }
95+
96+ componentDidUpdate ( ) {
97+ try {
98+ // eslint-disable-next-line react/no-find-dom-node
99+ const domNode = ReactDOM . findDOMNode ( this ) ;
100+
101+ renderMath ( domNode ) ;
102+ } catch ( e ) {
103+ // Added try-catch block to handle "Unable to find node on an unmounted component" error from tests, thrown because of the usage of shallow
104+ console . error ( 'DOM not mounted' ) ;
105+ }
106+ }
107+
82108 add = ( ) => {
83109 const { model, categories : oldCategories } = this . props ;
84110 const { categoriesPerRow, correctResponse, allowAlternateEnabled } = model ;
0 commit comments