From c26e2551fdb557588d23f8aa283658f098c5358c Mon Sep 17 00:00:00 2001 From: Michael McGahan Date: Fri, 9 Jun 2017 13:00:08 +1200 Subject: [PATCH] fix: always set state.error, return markup from initial render --- src/index.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index 3d6d3bb..10e3cf1 100755 --- a/src/index.js +++ b/src/index.js @@ -54,8 +54,11 @@ export class RedBoxError extends Component { // Other eval follow a specific pattern and can be easily parsed. const isEval = stackLines[1].search(/\(eval at/) !== -1 - if (!isEval) + if (!isEval) { + // mapping will be deferred until `componentDidMount` + this.state = { error, mapped: false } return + } // The first line is the error message. let fixedLines = [stackLines.shift()] @@ -112,11 +115,9 @@ export class RedBoxError extends Component { } render () { - // The error is received as a property and after it gets mapped to the source - // map, it’ll be stored in the state. - const {error, mapped} = this.state - if (!mapped) - return null + // The error is received as a property to initialize state.error, which may + // be updated when it is mapped to the source map. + const {error} = this.state const {className} = this.props const {redbox, message, stack, frame} = assign({}, style, this.props.style)