Closed haihuynhsts closed 2 years ago
Redux states are not initialized may be. Before extracting states const home = useSelector(selectHome)
,
initialize redux state like const {actions} = useHomeSlice()
example:
import { useHomeSlice } from './pages/HomePage/slice'
const { actions } = userHomeSlice()
const home = useSelector(selectHome)
console.log(home)
Oh, it works like a charm. Thank you, now I understand why the error happened.
Before opening a new issue, please take a moment to review our community guidelines to make the contribution process easy and effective for everyone involved.
Description
The state in Redux store returns
undefined
Steps to reproduce
Steps to reproduce the behavior:
I created a react app by using the command
yarn create react-app --template cra-template-rb my-app
After the app is created, everything just works perfectly. But after I run the command
yarn cleanAndSetup
I created a new slice using
yarn generate slice
When I tried to use the slice in my home page, then the page doesn't work anymore
Here is what I found from the browser console:
Turns out, it's because the
state
value in the below picture isundefined
Expected behavior The
state
value shouldn't beundefined
Screenshots If applicable, add screenshots to help explain your problem.
Versions