this is my selector file for Login
component
import { createSelector } from 'reselect';
const authentication = () => (state) => state.get('login');
const getCurrentAuthData = () => createSelector(
authentication,
(loginState) => loginState.get('currentUser')
);
export {
authentication,
getCurrentAuthData,
};
and this is the reducer file which describes the state for Login
component
import { fromJS } from 'immutable';
import { loginConstants } from './constant';
let user = JSON.parse(localStorage.getItem('user'));
const initialState = user ? fromJS({ loggedIn: true, user }) : fromJS({});
function loginReducer(state = initialState, action) {
switch (action.type) {
case loginConstants.LOGIN_REQUEST:
return state
.set('loggingIn', true)
.set('user', action.true)
case loginConstants.LOGIN_SUCCESS:
return state
.set('loggedIn', true)
.set('user', action.true)
case loginConstants.LOGIN_FAILURE:
return fromJS({});
case loginConstants.LOGOUT_REQUEST:
return fromJS({});
case loginConstants.LOGOUT_SUCCESS:
return fromJS({});
case loginConstants.LOGOUT_FAILURE:
return fromJS({});
default:
return state
}
}
export default loginReducer;
Now the problem is it's giving error as loginState.get is not a function.
PS I am referencing the React-boilerplate [https://github.com/react-boilerplate/react-boilerplate] for code and basically copy-pasting code (learning phase).