File tree Expand file tree Collapse file tree 5 files changed +28
-21
lines changed Expand file tree Collapse file tree 5 files changed +28
-21
lines changed Original file line number Diff line number Diff line change 2727    "html-webpack-plugin" : " 2.29.0" 
2828    "jest" : " 20.0.4" 
2929    "mobx" : " ^3.2.2" 
30+     "mobx-react" : " ^4.2.2" 
3031    "object-assign" : " 4.1.1" 
3132    "postcss-flexbugs-fixes" : " 3.2.0" 
3233    "postcss-loader" : " 2.0.6" 
Original file line number Diff line number Diff line change @@ -3,12 +3,9 @@ import './App.css';
33
44import  Stories  from  './Stories' ; 
55
6- const  App  =  ( {  stories ,  onArchive  } )  => 
6+ const  App  =  ( )  => 
77  < div  className = "app" > 
8-     < Stories 
9-       stories = { stories } 
10-       onArchive = { onArchive } 
11-     /> 
8+     < Stories  /> 
129  </ div > 
1310
1411export  default  App ; 
Original file line number Diff line number Diff line change 11import  React  from  'react' ; 
2+ import  {  inject ,  observer  }  from  'mobx-react' ; 
23import  './Stories.css' ; 
34import  Story  from  './Story' ; 
45
@@ -24,16 +25,16 @@ const COLUMNS = {
2425  } , 
2526} ; 
2627
27- const  Stories  =  ( {  stories ,  onArchive  } )  => 
28+ const  Stories  =  ( {  storyStore ,  archiveStore  } )  => 
2829  < div  className = "stories" > 
2930    < StoriesHeader  columns = { COLUMNS }  /> 
3031
31-     { ( stories  ||  [ ] ) . map ( story  => 
32+     { ( storyStore . readableStories  ||  [ ] ) . map ( story  => 
3233      < Story 
3334        key = { story . objectID } 
3435        story = { story } 
3536        columns = { COLUMNS } 
36-         onArchive = { onArchive } 
37+         onArchive = { archiveStore . archiveStory } 
3738      /> 
3839    ) } 
3940  </ div > 
@@ -50,4 +51,4 @@ const StoriesHeader = ({ columns }) =>
5051    ) } 
5152  </ div > 
5253
53- export  default  Stories ; 
54+ export  default  inject ( 'storyStore' ,   'archiveStore' ) ( observer ( Stories ) ) ; 
Original file line number Diff line number Diff line change 11import  React  from  'react' ; 
22import  ReactDOM  from  'react-dom' ; 
3- import  {  autorun  }  from  'mobx' ; 
3+ import  {  Provider  }  from  'mobx-react ' ; 
44import  './index.css' ; 
55import  App  from  './components/App' ; 
66import  store  from  './stores' ; 
77import  registerServiceWorker  from  './registerServiceWorker' ; 
88
9- function  render ( )  { 
10-   ReactDOM . render ( 
11-     < App 
12-       stories = { store . storyStore . readableStories } 
13-       onArchive = { ( objectID )  =>  store . archiveStore . archiveStory ( objectID ) } 
14-     /> , 
15-     document . getElementById ( 'root' ) 
16-   ) ; 
17- } 
18- 
19- autorun ( render ) ; 
9+ ReactDOM . render ( 
10+   < Provider  {  ...store  } > 
11+     < App  /> 
12+   </ Provider > , 
13+   document . getElementById ( 'root' ) 
14+ ) ; 
2015
2116registerServiceWorker ( ) ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments