-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
72 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
import React from 'react' | ||
import React from 'react'; | ||
|
||
const NavigationBar = ({ router, token }) => ( | ||
<div id="navigation-bar"> | ||
const NavigationBar = ({ router, token, setToken }) => ( | ||
<nav id="navigation-bar"> | ||
<button name="basic" onClick={() => router.push('/basic')}>Try Basic Use</button> | ||
<button name="parameter" onClick={() => router.push('/parameter/kuu/12')}>Try URL Parameters </button> | ||
<button name="cache" onClick={() => router.push('/cache')}>Try Cache</button> | ||
<button name="dynamic" onClick={() => router.push('/dynamic/')}>Try Dynamic Routing</button> | ||
<button name="one" onClick={() => router.push('/exclusive/one')}>Render First Route</button> | ||
<button name="two" onClick={() => router.push('/exclusive/two')}>Render Second Route</button> | ||
<button name="three" onClick={() => router.push('/exclusive/foobar')}>Render Third Route</button> | ||
<button name="profile" onClick={() => { | ||
if (token) { | ||
router.push('/profile'); | ||
} else { | ||
router.push('/login'); | ||
} | ||
}}>Check Out My Profile</button> | ||
</div> | ||
<button name="profile" onClick={() => router.push('/profile')}>My Profile (Try Login)</button> | ||
{ | ||
token && | ||
<button name="logout" onClick={() => { | ||
if (window.confirm('Logout?')) { | ||
setToken(null); | ||
router.push('/'); | ||
} | ||
}}>Logout</button> | ||
} | ||
<br /> | ||
<div> | ||
<span style={{ fontSize: 14 }}>Try Exclusive Routing : </span> | ||
<button name="one" onClick={() => router.push('/exclusive/one')}>Render First Route</button> | ||
<button name="two" onClick={() => router.push('/exclusive/two')}>Render Second Route</button> | ||
<button name="three" onClick={() => router.push('/exclusive/foobar')}>Render Third Route</button> | ||
</div> | ||
</nav> | ||
); | ||
|
||
export default NavigationBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
import React from 'react'; | ||
import Routing from '../src'; | ||
|
||
const Profile = ({ router }) => ( | ||
<div id="profile"> | ||
My Profile | ||
<br /> | ||
balance: $ 100.00 | ||
</div> | ||
); | ||
class Profile extends React.Component { | ||
componentDidMount() { | ||
if (!this.props.token) { | ||
sessionStorage.setItem('loginRedirect', '/profile'); | ||
this.props.router.push('/login'); | ||
alert('Need Login'); | ||
} | ||
} | ||
render() { | ||
return ( | ||
<div id="profile"> | ||
My Profile | ||
<br /> | ||
balance: $ 100.00 | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default Routing(Profile); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,4 +53,4 @@ | |
"jest": { | ||
"testURL": "http://localhost" | ||
} | ||
} | ||
} |