From 3297d01e78f871fd87980252fdae1aa68716ff7c Mon Sep 17 00:00:00 2001 From: Delucse <46593742+Delucse@users.noreply.github.com> Date: Tue, 8 Sep 2020 11:30:34 +0200 Subject: [PATCH] Revert "CodeViewer with referenced height of parent div" This reverts commit dddd9432db920b78b6b8567303d5facc8f2c8ae6. --- src/components/CodeViewer.js | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/components/CodeViewer.js b/src/components/CodeViewer.js index ac540f5..8477cc0 100644 --- a/src/components/CodeViewer.js +++ b/src/components/CodeViewer.js @@ -32,10 +32,10 @@ const AccordionSummary = withStyles((theme) => ({ root: { backgroundColor: theme.palette.secondary.main, borderBottom: `1px solid white`, - marginBottom: '-1px', - minHeight: '50px', + marginBottom: -1, + minHeight: 50, '&$expanded': { - minHeight: '50px', + minHeight: 50, }, }, content: { @@ -55,24 +55,15 @@ const AccordionDetails = withStyles((theme) => ({ class CodeViewer extends Component { - constructor(props){ - super(props); - this.state = { - expanded: true, - componentHeight: null - }; - this.myDiv = React.createRef(); + state = { + expanded: true } componentDidMount() { Prism.highlightAll(); - this.setState({componentHeight: this.myDiv.current.offsetHeight+'px'}); } - componentDidUpdate(props, state) { - if(this.myDiv.current && this.myDiv.current.offsetHeight+'px' !== this.state.componentHeight){ - this.setState({componentHeight: this.myDiv.current.offsetHeight+'px'}); - } + componentDidUpdate() { Prism.highlightAll(); } @@ -83,9 +74,8 @@ class CodeViewer extends Component { render() { var curlyBrackets = '{ }'; var unequal = '<>'; - console.log('render', this.myDiv); return ( - + {curlyBrackets}
Arduino Quellcode
- +
               
                 {this.props.arduino}
@@ -114,7 +104,7 @@ class CodeViewer extends Component {
             {unequal}
             
XML Blöcke
- +
               
                 {`${this.props.xml}`}