From b9f6766a66d27200970cdbcc1f840665b997d58e Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Mon, 28 May 2018 12:16:44 -0400 Subject: [PATCH] Using React.createRef --- src/components/App/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/App/index.js b/src/components/App/index.js index d6472b2..3affa72 100644 --- a/src/components/App/index.js +++ b/src/components/App/index.js @@ -18,6 +18,8 @@ const syntaxes = { class App extends React.PureComponent { state = {} + image = React.createRef() + componentDidMount() { window.addEventListener('hashchange', this.handleHashChange); this.handleHashChange(); @@ -116,14 +118,12 @@ class App extends React.PureComponent { syntax, expr }, async () => { - await this.image.doReflow(); - this.setSvgUrl(this.image.svg.current); - this.setPngUrl(this.image.svg.current); + await this.image.current.doReflow(); + this.setSvgUrl(this.image.current.svg.current); + this.setPngUrl(this.image.current.svg.current); }); } - imageRef = image => this.image = image - render() { const { svgUrl, pngUrl, permalinkUrl, syntax, expr, image } = this.state; const downloadUrls = [ @@ -146,7 +146,7 @@ class App extends React.PureComponent {

Sample warning message

{ image &&
- +
} ; }