From 2b3cf62d87f632ee1eae4b19044d0ee3aef4fb09 Mon Sep 17 00:00:00 2001 From: Dan Bryant Date: Sun, 18 Aug 2019 10:16:00 -0700 Subject: [PATCH 1/2] ignore /lib and yarn.lock --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index a56a7ef..3017d0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules +/lib +/yarn.lock From 60d1703f08b1520df394b858624dbea2006cdf2d Mon Sep 17 00:00:00 2001 From: Dan Bryant Date: Sun, 18 Aug 2019 10:29:59 -0700 Subject: [PATCH 2/2] fix for isue #6: https://github.com/iamdustan/yellowbox-react/issues/6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Directly attaching an event handler that sets state will trigger thhis error. In my case using reactstrap’s (https://reactstrap.github.io/components/modals/) Example: where this.toggleModal() is *doing a this.setState() What happens in my case is issue #6 in Yellowbox hides the source of the problem, in this case directly calling the Modal.toggle function when the component is mounting which causes a React.setStateLoopOfDoom error. This patch makes sure that this._listener.remove() is a function before trying to call it, thereby allowing the real problem (state loop) to show up. *Not sure it matters but I’m using immer to set state: https://github.com/immerjs/immer --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 1a9dbb8..bd3ded9 100644 --- a/src/index.js +++ b/src/index.js @@ -111,7 +111,7 @@ class YellowBox extends Component { } componentWillUnmount() { - if (this._listener) { + if (this._listener && typeof this._listener.remove === 'function') { this._listener.remove(); } }