Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG2053-Project
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
Martin Wighus Holtmon
PROG2053-Project
Commits
2b9445ed
Commit
2b9445ed
authored
3 years ago
by
Martin Wighus Holtmon
Browse files
Options
Downloads
Patches
Plain Diff
firstpart/Problem4 - Finished - Made a button to switch between the componenets
parent
dc5a5b03
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
projectFirstPart/p2.html
+1
-1
1 addition, 1 deletion
projectFirstPart/p2.html
projectFirstPart/p4.html
+1
-0
1 addition, 0 deletions
projectFirstPart/p4.html
projectFirstPart/p4.jsx
+24
-2
24 additions, 2 deletions
projectFirstPart/p4.jsx
with
26 additions
and
3 deletions
projectFirstPart/p2.html
+
1
−
1
View file @
2b9445ed
This diff is collapsed.
Click to expand it.
projectFirstPart/p4.html
+
1
−
0
View file @
2b9445ed
...
...
@@ -4,6 +4,7 @@
<title>
CS142 Class Project
</title>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<script
src=
"modelData/states.js"
></script>
<script
src=
"modelData/example.js"
></script>
</head>
<body>
<div
id=
"reactapp"
>
...
...
This diff is collapsed.
Click to expand it.
projectFirstPart/p4.jsx
+
24
−
2
View file @
2b9445ed
import
React
from
'
react
'
;
import
ReactDOM
from
'
react-dom
'
;
import
States
from
'
./components/states/States
'
;
import
Example
from
'
./components/example/Example
'
;
//import States from './components/states/States';
class
P4
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
handleButtonClick
=
this
.
handleButtonClick
.
bind
(
this
);
this
.
state
=
{
activePage
:
States
,
nextPage
:
Example
}
console
.
log
(
this
.
state
.
activePage
.
name
)
}
handleButtonClick
()
{
this
.
setState
({
activePage
:
this
.
state
.
nextPage
,
nextPage
:
this
.
state
.
activePage
})
}
render
()
{
return
(
<
div
>
<
button
type
=
"button"
onClick
=
{
this
.
handleButtonClick
}
>
Switch to
{
this
.
state
.
nextPage
.
name
}
</
button
>
<
this
.
state
.
activePage
/>
</
div
>
)
}
}
ReactDOM
.
render
(
<
h1
>
page4
</
h1
>,
<
P4
/
>,
document
.
getElementById
(
'
reactapp
'
),
);
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