I am not sure if this is common practice, but while I was going through the highly popular react-boilerplate app I noticed that the default value of the store keys were always getting set to false
regardless of whether the actual type is Array
, Object
, Number
or String
.
// The initial state of the App
const initialState = fromJS({
loading: false,
error: false,
currentUser: false, // String
userData: {
repositories: false, // Array of Objects
},
});
function appReducer(state = initialState, action) {
.....
Is there a best practice in play here? Because in this implementation the data type in the JSX component will need to be Array or Boolean
instead of just Array
which is what the type should be in the first place.
repos: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
Thank you in advance.