From a12583f762e6314b137df9476f50fe78a9e24b87 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Mon, 27 Mar 2017 17:27:35 +0200 Subject: [PATCH] Fix the use of MobX in playground (#5294) * Register new playground component onMount * No need of observer * Fix tests --- js/src/playground/store.js | 15 ++------------- js/src/playground/store.spec.js | 7 ------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/js/src/playground/store.js b/js/src/playground/store.js index e627cdcc1..db0df38b4 100644 --- a/js/src/playground/store.js +++ b/js/src/playground/store.js @@ -14,12 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import { action, observable } from 'mobx'; +import { action } from 'mobx'; let instance = null; export default class PlaygroundStore { - @observable components = []; + components = []; static get () { if (!instance) { @@ -35,17 +35,6 @@ export default class PlaygroundStore { @action add (component) { - const name = component.type.displayName || component.type.name; - const hasComponent = this.components.find((c) => { - const cName = c.type.displayName || c.type.name; - - return name && cName && cName === name; - }); - - if (hasComponent) { - return; - } - this.components.push(component); } } diff --git a/js/src/playground/store.spec.js b/js/src/playground/store.spec.js index 27db2411b..172d244fd 100644 --- a/js/src/playground/store.spec.js +++ b/js/src/playground/store.spec.js @@ -31,11 +31,4 @@ describe('playground/store', () => { PlaygroundStore.register(); expect(store.components.length).greaterThan(0); }); - - it('adds new Components only once', () => { - PlaygroundStore.register(); - PlaygroundStore.register(); - - expect(store.components.filter((c) => /QrCode/i.test(c.type.name)).length).equal(1); - }); });