While creating the reducer, i have set the initial state but while loading the component for the first time, i am getting an empty state.
reducer file -
const initialValues = { geo: { latitude: 0, longitude: 0 } }
const emp = (state = initialValues, action) => {
switch (action.type) {
case 'bike': {
return { ...state, data: action.payload }
}
case 'car': {
return { ...state, headers: action.payload }
}
default:
return state
}
}
component file-
export default function Emp() {
const emp = useSelector(state => state)
console.log('emp state', emp)
}
index.js
const store = createStore(reducer,
{},
compose(
applyMiddleware(
loggingMiddleware,
),
window.devToolsExtension ? window.devToolsExtension() : f => f
)
)