Skip to content

Commit 0421095

Browse files
author
woi
committed
use user as List
1 parent 81c8ce6 commit 0421095

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

App/Stores/Example/InitialState.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Map } from 'immutable'
1+
import { Map, List } from 'immutable'
22

33
/**
44
* The initial values for the redux state.
55
*/
66
export const INITIAL_STATE = Map({
7-
user: null,
7+
user: List(),
88
userIsLoading: false,
99
userErrorMessage: null,
1010
})

App/Stores/Example/Reducers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { INITIAL_STATE } from './InitialState'
88
import { createReducer } from 'reduxsauce'
99
import { ExampleTypes } from './Actions'
10+
import { List } from 'immutable'
1011

1112
export const fetchUserLoading = (state) =>
1213
state.merge({
@@ -23,7 +24,7 @@ export const fetchUserSuccess = (state, { user }) =>
2324

2425
export const fetchUserFailure = (state, { errorMessage }) =>
2526
state.merge({
26-
user: null,
27+
user: List(),
2728
userIsLoading: false,
2829
userErrorMessage: errorMessage,
2930
})

App/Stores/Example/Selectors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
export const liveInEurope = (state) => {
10-
if (!state.example.get('user')) return null
10+
if (state.example.get('user').isEmpty()) return null
1111

1212
// For this example, we imagine this cities are european cities
1313
let europeanCities = ['Gwenborough', 'Wisokyburgh', 'McKenziehaven', 'South Elvis', 'Roscoeview']

0 commit comments

Comments
 (0)