-
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.
Added HookClock, UserPage, and HelloUser components. Bug existing for…
… importing and employing HelloUser
- Loading branch information
Showing
10 changed files
with
1,783 additions
and
116 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react' | ||
import { connect } from 'net'; | ||
|
||
const HelloUser = ({ username }) => | ||
username ? ( | ||
<p>Hello, {username}</p> | ||
) : ( | ||
<p>No user detected</p> | ||
); | ||
|
||
// export default HelloUser | ||
export default connect( | ||
(state) => ({ username: state.auth.username }), | ||
null | ||
)(HelloUser); |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { useState, useEffect } from 'react' | ||
|
||
const Clock = () => { | ||
const [date, setDate] = useState(new Date()) | ||
useEffect(()=> { | ||
const timer = setInterval( | ||
() => { | ||
setDate(new Date()) | ||
}, 1000 | ||
) | ||
return () => { | ||
clearInterval(timer) | ||
} | ||
}, []) | ||
return <span>{date.toLocaleTimeString()}</span> | ||
} | ||
|
||
export default Clock |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React, { useState, useEffect } from "react" | ||
|
||
|
||
const Counter = () => { | ||
const [count, setCount] = useState(0) | ||
// const [apiDate, setApiData] = useState({ loading: false, value: null}) | ||
useEffect(()=> {document.title = `${count} hits`;}) | ||
// ... which is componentDidMount & componentDidUpdate | ||
// if you return within useEffect, it is the same as componentWillUnmount | ||
return ( | ||
<div> | ||
<p>You clicked {count} times</p> | ||
<button onClick={() => setCount(count + 1)}>Click me</button> | ||
</div> | ||
) | ||
} | ||
export default Counter |