Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IT2810 H21
Team 05
prosjekt4
Commits
2055af36
Commit
2055af36
authored
Nov 17, 2021
by
Peter Skaar Nordby
Browse files
La til refresh for ratingliste
parent
e1d651f2
Changes
1
Show whitespace changes
Inline
Side-by-side
components/UserRatings.tsx
View file @
2055af36
import
*
as
React
from
"
react
"
;
import
{
useEffect
,
useState
}
from
"
react
"
;
import
{
FlatList
,
StyleSheet
}
from
"
react-native
"
;
import
{
FlatList
,
RefreshControl
,
StyleSheet
}
from
"
react-native
"
;
import
{
AirbnbRating
}
from
"
react-native-ratings
"
;
import
{
useDispatch
,
useSelector
}
from
"
react-redux
"
;
import
{
Text
,
View
}
from
"
../components/Themed
"
;
...
...
@@ -15,9 +15,18 @@ export default function UserRatings(): JSX.Element {
const
auth
:
AuthState
=
useSelector
(({
auth
}:
ApplicationState
)
=>
auth
);
const
[
refreshing
,
setRefreshing
]
=
React
.
useState
(
false
);
const
onRefresh
=
React
.
useCallback
(()
=>
{
setRefreshing
(
true
);
if
(
auth
.
token
)
{
dispatch
(
getRatings
({
token
:
auth
.
token
}));
}
setRefreshing
(
false
);
},
[
refreshing
]);
useEffect
(()
=>
{
if
(
auth
.
token
)
{
console
.
log
(
auth
.
token
);
dispatch
(
getRatings
({
token
:
auth
.
token
}));
}
},
[]);
...
...
@@ -33,9 +42,12 @@ export default function UserRatings(): JSX.Element {
<
View
style
=
{
styles
.
separator
}
lightColor
=
"#rgba(0,0,0,0.2)"
darkColor
=
"rgba(255,255,255,0.2)"
darkColor
=
"
#
rgba(255,255,255,0.2)"
/>
)
}
refreshControl
=
{
<
RefreshControl
refreshing
=
{
refreshing
}
onRefresh
=
{
onRefresh
}
/>
}
/>
);
}
...
...
Write
Preview
Supports
Markdown
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