Skip to content

Commit 780eaaa

Browse files
committed
part 10
1 parent 650710d commit 780eaaa

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function render() {
1010
ReactDOM.render(
1111
<App
1212
stories={store.storyStore.readableStories}
13-
onArchive={(objectID) => store.archiveStore.archivedStoryIds.push(objectID)}
13+
onArchive={(objectID) => store.archiveStore.archiveStory(objectID)}
1414
/>,
1515
document.getElementById('root')
1616
);

src/stores/archiveStore.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import { observable } from 'mobx';
1+
import { observable, action } from 'mobx';
22

33
class ArchiveStore {
44
@observable archivedStoryIds = [];
55

66
constructor(rootStore) {
77
this.rootStore = rootStore;
88
}
9+
10+
@action archiveStory = id =>
11+
this.archivedStoryIds.push(id);
912
}
1013

1114
export default ArchiveStore;

src/stores/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import { useStrict } from 'mobx';
2+
13
import StoryStore from './storyStore';
24
import ArchiveStore from './archiveStore';
35

6+
useStrict(true);
7+
48
class RootStore {
59
constructor() {
610
this.storyStore = new StoryStore(this);

0 commit comments

Comments
 (0)