temp 3
This commit is contained in:
19
src/App.tsx
19
src/App.tsx
@@ -1,12 +1,27 @@
|
||||
import { createContext } from 'react'
|
||||
import { createContext, useEffect } from 'react'
|
||||
import RouterSetup from './RouterSetup'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { useDispatch, useSelector } from 'react-redux'
|
||||
import type { StoreType } from './stores'
|
||||
import Loading from './components/Loading'
|
||||
import { Apis } from './apis'
|
||||
import { userAction } from './stores/slices/user.slice'
|
||||
|
||||
export default function App() {
|
||||
const userStore = useSelector((store: StoreType) => store.user)
|
||||
const dipatch = useDispatch()
|
||||
|
||||
useEffect(() => {
|
||||
if(userStore.data && !userStore.loading) {
|
||||
try {
|
||||
Apis.cart.getCartByUserId(userStore.data.id)
|
||||
.then(res => {
|
||||
dipatch(userAction.initCartData(res))
|
||||
})
|
||||
}catch(err) {
|
||||
|
||||
}
|
||||
}
|
||||
}, [userStore.data, userStore.loading])
|
||||
return (
|
||||
<>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user