Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
classwork-65
Project
Project
Details
Activity
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
Нұрасыл Қайратұлы
classwork-65
Commits
03ea679c
Commit
03ea679c
authored
Jan 23, 2025
by
Нұрасыл Қайратұлы
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parent
cdd27d19
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
11 deletions
+22
-11
App.tsx
src/App.tsx
+1
-1
Contacts.tsx
src/containers/Contacts.tsx
+3
-2
Home.tsx
src/containers/Home.tsx
+3
-4
hooks.ts
src/store/hooks.ts
+7
-0
home.slice.ts
src/store/slices/home.slice.ts
+2
-2
store.ts
src/store/store.ts
+6
-2
No files found.
src/App.tsx
View file @
03ea679c
...
...
@@ -2,7 +2,7 @@ import {BrowserRouter, Routes, Route} from 'react-router-dom'
import
Home
from
'./containers/Home'
import
Contacts
from
'./containers/Contacts'
import
{
Provider
}
from
'react-redux'
import
{
store
}
from
'./store/store'
import
store
from
'./store/store'
const
App
=
()
=>
{
return
(
...
...
src/containers/Contacts.tsx
View file @
03ea679c
import
{
useSelector
}
from
'react-redux'
import
{
useAppSelector
}
from
"../store/hooks"
;
const
Contacts
=
()
=>
{
const
state
=
useSelector
((
state
)
=>
state
.
contact
.
contactList
)
const
state
=
use
App
Selector
((
state
)
=>
state
.
contact
.
contactList
)
console
.
log
(
state
,
"CONTACTS"
);
...
...
src/containers/Home.tsx
View file @
03ea679c
import
{
useSelector
}
from
"react-redux"
import
{
addRandomContact
}
from
"../store/slices/contact.slice"
;
import
{
useDispatch
}
from
"react-redux"
;
import
{
useNavigate
}
from
"react-router-dom"
;
import
{
changeTitle
}
from
"../store/slices/home.slice"
;
import
{
useAppDispatch
,
useAppSelector
}
from
"../store/hooks"
;
const
Home
=
()
=>
{
const
dispatch
=
useDispatch
()
const
dispatch
=
use
App
Dispatch
()
const
navigate
=
useNavigate
()
const
state
=
use
Selector
((
state
)
=>
state
)
const
state
=
use
AppSelector
(
state
=>
state
)
console
.
log
(
state
,
"HOME"
);
...
...
src/store/hooks.ts
0 → 100644
View file @
03ea679c
import
{
useDispatch
,
useSelector
}
from
'react-redux'
import
type
{
TypedUseSelectorHook
}
from
'react-redux'
import
type
{
RootState
,
AppDispatch
}
from
'./store'
export
const
useAppDispatch
:
()
=>
AppDispatch
=
useDispatch
export
const
useAppSelector
:
TypedUseSelectorHook
<
RootState
>
=
useSelector
\ No newline at end of file
src/store/slices/home.slice.ts
View file @
03ea679c
import
{
createSlice
}
from
'@reduxjs/toolkit'
import
{
createSlice
,
PayloadAction
}
from
'@reduxjs/toolkit'
interface
IState
{
homeTitle
:
string
...
...
@@ -12,7 +12,7 @@ export const homeSlice = createSlice({
name
:
'home'
,
initialState
,
reducers
:
{
changeTitle
:
(
state
,
action
)
=>
{
changeTitle
:
(
state
,
action
:
PayloadAction
<
string
>
)
=>
{
state
.
homeTitle
=
action
.
payload
}
}
...
...
src/store/store.ts
View file @
03ea679c
...
...
@@ -2,9 +2,13 @@ import { configureStore } from '@reduxjs/toolkit'
import
{
contactSlice
}
from
'./slices/contact.slice'
import
{
homeSlice
}
from
'./slices/home.slice'
export
const
store
=
configureStore
({
const
store
=
configureStore
({
reducer
:
{
contact
:
contactSlice
.
reducer
,
home
:
homeSlice
.
reducer
}
})
\ No newline at end of file
})
export
type
RootState
=
ReturnType
<
typeof
store
.
getState
>
;
export
type
AppDispatch
=
typeof
store
.
dispatch
;
export
default
store
;
\ No newline at end of file
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