Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
COVID-19-Data-Integration
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Ivy Wang
COVID-19-Data-Integration
Commits
a1342843
Commit
a1342843
authored
3 years ago
by
PatrickMurphy99
Browse files
Options
Downloads
Patches
Plain Diff
printed out the selected country
oooof
parent
361678c0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontendreact/src/App.tsx
+9
-2
9 additions, 2 deletions
frontendreact/src/App.tsx
frontendreact/src/components/DropDown.tsx
+3
-1
3 additions, 1 deletion
frontendreact/src/components/DropDown.tsx
with
12 additions
and
3 deletions
frontendreact/src/App.tsx
+
9
−
2
View file @
a1342843
import
React
from
'
react
'
;
import
React
,
{
useEffect
,
useState
}
from
'
react
'
import
'
./App.css
'
;
import
DropDown
from
'
./components/DropDown
'
;
function
App
()
{
const
[
selectedCountry
,
changeCountry
]
=
useState
<
string
>
(
""
)
const
countryFunction
=
(
event
:
React
.
ChangeEvent
<
HTMLSelectElement
>
):
void
=>
{
changeCountry
(
event
.
target
.
value
);
}
return
(
<
div
className
=
"App"
>
<
DropDown
geoOption
=
'countries'
name
=
'country_name'
code
=
'country_code'
/>
<
DropDown
geoOption
=
'countries'
name
=
'country_name'
code
=
'country_code'
changeFunction
=
{
countryFunction
}
/>
<
p
>
This is our selected country
{
selectedCountry
}
</
p
>
</
div
>
);
}
export
default
App
;
This diff is collapsed.
Click to expand it.
frontendreact/src/components/DropDown.tsx
+
3
−
1
View file @
a1342843
...
...
@@ -4,6 +4,7 @@ interface DropDownProp {
geoOption
:
string
;
name
:
string
;
code
:
string
;
changeFunction
(
event
:
React
.
ChangeEvent
<
HTMLSelectElement
>
):
void
;
}
...
...
@@ -18,7 +19,8 @@ export default function DropDown(props: DropDownProp) {
},
[
props
.
geoOption
]);
console
.
log
(
options
);
return
(
<
select
>
{
options
.
map
((
optionItem
:
any
)
=>
<
option
key
=
{
optionItem
[
props
.
code
]
}
<
select
onChange
=
{
props
.
changeFunction
}
>
{
options
.
map
((
optionItem
:
any
)
=>
<
option
key
=
{
optionItem
[
props
.
code
]
}
value
=
{
optionItem
[
props
.
name
]
}
>
{
optionItem
[
props
.
name
]
+
"
(
"
+
optionItem
[
props
.
code
]
+
"
)
"
}
</
option
>)
}
</
select
>
);
}
\ No newline at end of file
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