Open Jbarget opened 6 years ago
I'm not exactly sure what you mean by this in this case. Before the user is authenticated or not, the state needs to be null. It then becomes false if the user is not authenticated or the associated user info object if the user is authenticated. This is how Stephen Grider did it in his Udemy course.
Do you mean we should have all of the user object fields elucidated and set to null initially? Perhaps add a separate field for authenticated null, false or true?
similar to this:
export const initialState = {
assetLocks: {},
own: {},
members: {},
count: 0,
isSubscribed: false
};
just allows you to actually have initial state and gives you an idea of whats to come
you want to make your reducers as futureproof as possible. If it just returns one value then later down the line if you need to add something to it, it will be a fair bit harder
in the same breath you want your reducers to be as flat as possible as well
Ah I see. Where would we put the initialState constant? in the reducer index.js? The initial state is set in each individual reducer file in the default values of the function but I see what you mean, just not sure where you would actually use that variable?
@shannonjensen each individual reducer will have its own initial state. I tend to put it at the top of each of the reducers' file
https://github.com/fac-12/FAC-Events-Search/blob/master/client/src/reducers/authReducer.js#L3
i find its always helpful to have values as the initial state so that you can easily see what the reducer is expected to look like