Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
Newspaper Frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lap nguyen
Newspaper Frontend
Commits
6cdc14d6
Commit
6cdc14d6
authored
Dec 16, 2022
by
Ken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add reset page for home
parent
4addc5b6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
homePageSlice.ts
src/pages/home/homePageSlice.ts
+7
-2
index.tsx
src/pages/home/index.tsx
+6
-1
No files found.
src/pages/home/homePageSlice.ts
View file @
6cdc14d6
...
...
@@ -17,7 +17,11 @@ export const getNews = createAsyncThunk(
const
home
=
createSlice
({
name
:
"home"
,
initialState
,
reducers
:
{},
reducers
:
{
handleResetNews
:
(
state
)
=>
{
state
.
newsData
=
[];
},
},
extraReducers
:
(
builder
)
=>
{
builder
.
addCase
(
getNews
.
fulfilled
,
(
state
,
action
:
PayloadAction
<
any
>
)
=>
{
const
{
collection
}
=
action
.
payload
.
data
;
...
...
@@ -31,5 +35,6 @@ const home = createSlice({
},
});
const
{
reducer
}
=
home
;
const
{
reducer
,
actions
}
=
home
;
export
const
{
handleResetNews
}
=
actions
;
export
default
reducer
;
src/pages/home/index.tsx
View file @
6cdc14d6
...
...
@@ -3,7 +3,7 @@ import { homeSelector } from "app/selectors";
import
WrapperContainer
from
"components/WrapperContainer"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
Newspaper
from
"../../components/Newspaper"
;
import
{
getNews
}
from
"./homePageSlice"
;
import
{
getNews
,
handleResetNews
}
from
"./homePageSlice"
;
import
{
IPagination
}
from
"pages/interface"
;
import
{
useInView
}
from
"react-intersection-observer"
;
import
{
CircularProgress
}
from
"@mui/material"
;
...
...
@@ -50,6 +50,11 @@ const HomePage = () => {
}
},
[
inView
]);
useEffect
(()
=>
{
dispatch
(
handleResetNews
());
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[]);
return
(
<
main
className=
"homePage"
>
<
WrapperContainer
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment