-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCharacterView.jsx
47 lines (42 loc) · 1.28 KB
/
CharacterView.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { useEffect } from 'react';
import { MvMain } from '@layout/MvMain/MvMain';
import { useDispatch, useSelector } from 'react-redux';
import { getCharactersAction } from '@redux/actions/getCharactersAction';
import { CharacterViewCharactersSection } from '@views/CharacterView/sections/CharacterViewCharactersSection/CharacterViewCharactersSection';
import { CharacterViewPaginationSection } from '@views/CharacterView/sections/CharacterViewPaginationSection/CharacterViewPaginationSection';
import { setLoadingAction } from '@redux/actions/setLoadingAction';
/**
* CharacterView.
*
* Purpose:
* - Render page characters.
*
* @returns page with a list of characters
*/
const CharacterView = () => {
const dispatch = useDispatch();
/**
* offset.
*
* Purpose:
* - Capture a number from reducer.
*/
const offset = useSelector((store) => store.changeCharctersOffsetReducer.offset);
/**
* useEffect.
*
* Purpose:
* - Dispatch an action to get all characters.
*/
useEffect(() => {
dispatch(setLoadingAction());
dispatch(getCharactersAction({ offset: offset }));
}, [dispatch, offset]);
return (
<MvMain>
<CharacterViewPaginationSection />
<CharacterViewCharactersSection />
</MvMain>
);
};
export default CharacterView;