diff --git a/src/index.js b/src/index.js index e52b4c5..2070f04 100644 --- a/src/index.js +++ b/src/index.js @@ -10,7 +10,7 @@ function render() { ReactDOM.render( store.archiveStore.archivedStoryIds.push(objectID)} + onArchive={(objectID) => store.archiveStore.archiveStory(objectID)} />, document.getElementById('root') ); diff --git a/src/stores/archiveStore.js b/src/stores/archiveStore.js index c166298..d434053 100644 --- a/src/stores/archiveStore.js +++ b/src/stores/archiveStore.js @@ -1,4 +1,4 @@ -import { observable } from 'mobx'; +import { observable, action } from 'mobx'; class ArchiveStore { @observable archivedStoryIds = []; @@ -6,6 +6,9 @@ class ArchiveStore { constructor(rootStore) { this.rootStore = rootStore; } + + @action archiveStory = id => + this.archivedStoryIds.push(id); } export default ArchiveStore; \ No newline at end of file diff --git a/src/stores/index.js b/src/stores/index.js index 33b1323..b0bdff8 100644 --- a/src/stores/index.js +++ b/src/stores/index.js @@ -1,6 +1,10 @@ +import { useStrict } from 'mobx'; + import StoryStore from './storyStore'; import ArchiveStore from './archiveStore'; +useStrict(true); + class RootStore { constructor() { this.storyStore = new StoryStore(this);