Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IT2810 Project 4
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Ringdalen Thrane
IT2810 Project 4
Commits
f8bfce48
Commit
f8bfce48
authored
2 years ago
by
Ola Vanni Flaata
Browse files
Options
Downloads
Patches
Plain Diff
Fjernet gamle useEffect som overskrev useQuery, og endret så den fungerte riktig.
parent
290115d3
No related branches found
No related tags found
No related merge requests found
Pipeline
#195393
failed
2 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
webdev-p3/src/components/Pokedisplay/Pokedisplay.tsx
+9
-32
9 additions, 32 deletions
webdev-p3/src/components/Pokedisplay/Pokedisplay.tsx
with
9 additions
and
32 deletions
webdev-p3/src/components/Pokedisplay/Pokedisplay.tsx
+
9
−
32
View file @
f8bfce48
...
@@ -14,8 +14,7 @@ type pokemon = {
...
@@ -14,8 +14,7 @@ type pokemon = {
pokeindex
:
number
,
pokeindex
:
number
,
name
:
string
,
name
:
string
,
img
:
object
,
img
:
object
,
type1
:
string
,
types
:
string
[],
type2
:
string
|
null
,
prevevo
:
[]
|
null
,
prevevo
:
[]
|
null
,
nextevo
:
[]
|
null
nextevo
:
[]
|
null
}
}
...
@@ -24,29 +23,8 @@ type pokemon = {
...
@@ -24,29 +23,8 @@ type pokemon = {
export
default
function
Pokedisplay
(){
export
default
function
Pokedisplay
(){
const
[
page
,
setPage
]
=
useState
(
1
);
const
[
page
,
setPage
]
=
useState
(
1
);
useEffect
(()
=>
{
useEffect
(()
=>
{
getPokemonList
([
"
pokeIndex
"
,
"
name
"
,
"
types
"
,
"
img
"
],
page
).
then
((
data
)
=>
{
console
.
log
(
data
);})
console
.
log
(
data
);
if
(
data
==
null
){
return
}
var
list
=
data
.
pokemonList
.
map
((
pokemon
:
any
)
=>
{
return
{
pokeindex
:
pokemon
.
pokeIndex
,
name
:
pokemon
.
name
,
img
:
pokemon
.
img
,
type1
:
pokemon
.
types
[
0
],
type2
:
pokemon
.
types
[
1
],
nextevo
:
pokemon
.
nextEvo
,
prevevo
:
pokemon
.
prevEvo
}
}
)
setcurrentPokemon
(
list
);
});
},
[
page
]);
const
[
currentPokemon
,
setcurrentPokemon
]
=
useState
<
pokemon
[]
>
([]);
const
[
currentPokemon
,
setcurrentPokemon
]
=
useState
<
pokemon
[]
>
([]);
const
{
isOpen
,
toggle
,
triggerNumber
}
=
Modalhook
();
const
{
isOpen
,
toggle
,
triggerNumber
}
=
Modalhook
();
...
@@ -83,17 +61,16 @@ export default function Pokedisplay(){
...
@@ -83,17 +61,16 @@ export default function Pokedisplay(){
<
Modal
isOpen
=
{
isOpen
}
toggle
=
{
()
=>
toggle
(
-
1
)
}
pokemonIndex
=
{
triggerNumber
}
></
Modal
>
<
Modal
isOpen
=
{
isOpen
}
toggle
=
{
()
=>
toggle
(
-
1
)
}
pokemonIndex
=
{
triggerNumber
}
></
Modal
>
{
loading
?
<
p
>
Loading...
</
p
>
:
null
}
{
loading
?
<
p
>
Loading...
</
p
>
:
null
}
{
error
?
<
p
>
Error :(
</
p
>
:
null
}
{
error
?
<
p
>
Error :(
</
p
>
:
null
}
{
{
data
&&
data
&&
currentP
okemon
.
map
((
pokemon
,
poke
index
)
=>
{
data
.
p
okemon
List
.
map
((
pokemon
:
poke
mon
)
=>
{
//
console.log(pokemon);
console
.
log
(
pokemon
);
const
found1
=
colors
.
find
(
obj
=>
{
const
found1
=
colors
.
find
(
obj
=>
{
return
obj
.
poketype
===
pokemon
.
type
1
;
return
obj
.
poketype
===
pokemon
.
type
s
[
0
]
});
});
// console.log(found1);
// console.log(found1);
...
@@ -101,11 +78,11 @@ export default function Pokedisplay(){
...
@@ -101,11 +78,11 @@ export default function Pokedisplay(){
const
found2
=
colors
.
find
(
obj
=>
{
const
found2
=
colors
.
find
(
obj
=>
{
if
(
pokemon
.
type
2
===
undefined
){
if
(
pokemon
.
type
s
.
length
==
1
){
return
obj
.
poketype
===
pokemon
.
type
1
;
return
obj
.
poketype
===
pokemon
.
type
s
[
0
]
;
}
}
return
obj
.
poketype
===
pokemon
.
type
2
;
return
obj
.
poketype
===
pokemon
.
type
s
[
1
]
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment