From dec4b919ebefc740eb75cf1ccf3997c1ef8e7313 Mon Sep 17 00:00:00 2001 From: Peter Uithoven Date: Mon, 23 Nov 2015 14:22:49 +0100 Subject: [PATCH] Handle getting no debug_session --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a698403e..3b6eebc9 100644 --- a/README.md +++ b/README.md @@ -55,10 +55,15 @@ const finalCreateStore = compose( // Provides support for DevTools: devTools(), // Lets you write ?debug_session= in address bar to persist debug sessions - persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)[1]) + persistState(getPersistSession()) )(createStore); const store = finalCreateStore(reducer); + +function getPersistSession() { + const matches = window.location.href.match(/[?&]debug_session=([^&]+)\b/); + return (matches && matches.length > 0)? matches[1] : null; +} ``` Finally, include the `DevTools` in your page. You may pass either `LogMonitor` (the default one) or any of the custom monitors described below. For convenience, you can use `DebugPanel` to dock `DevTools` to some part of the screen, but you can put it also somewhere else in the component tree.