File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,11 @@ export default class Countries extends Component {
15
15
}
16
16
17
17
componentDidMount ( ) {
18
- this . props . fetchCountries ( ) ;
18
+ const { countries : { data } } = this . props ;
19
+
20
+ if ( ! data || data . length === 0 ) {
21
+ this . props . fetchCountries ( ) ;
22
+ }
19
23
}
20
24
21
25
Original file line number Diff line number Diff line change 1
- import { applyMiddleware , createStore } from "redux" ;
1
+ import { applyMiddleware , createStore , compose } from "redux" ;
2
2
import rootReducer from "./reducers" ;
3
3
import reduxThunk from "redux-thunk" ;
4
4
5
- export default createStore ( rootReducer , { } , applyMiddleware ( reduxThunk ) ) ;
5
+ let composeEnhancers = compose ;
6
+ let preloadedState = { } ;
7
+
8
+ if ( typeof window !== 'undefined' ) {
9
+ composeEnhancers = window . __REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose ;
10
+ preloadedState = window . INITIAL_STATE || { } ;
11
+ delete window . INITIAL_STATE ;
12
+ }
13
+
14
+ export default createStore (
15
+ rootReducer ,
16
+ preloadedState ,
17
+ composeEnhancers (
18
+ applyMiddleware ( reduxThunk ) ,
19
+ ) ,
20
+ ) ;
You can’t perform that action at this time.
0 commit comments