forked from robpark04/apeswap-frontend
-
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.
* feat: Add user data to redux * feat: Add a refresh context * chore: Clean hooks
- Loading branch information
1 parent
388d696
commit b5ab142
Showing
44 changed files
with
439 additions
and
419 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React, { useState, useEffect } from 'react' | ||
|
||
const FAST_INTERVAL = 10000 | ||
const SLOW_INTERVAL = 60000 | ||
|
||
const RefreshContext = React.createContext({ slow: 0, fast: 0 }) | ||
|
||
// This context maintain 2 counters that can be used as a dependencies on other hooks to force a periodic refresh | ||
const RefreshContextProvider = ({ children }) => { | ||
const [slow, setSlow] = useState(0) | ||
const [fast, setFast] = useState(0) | ||
|
||
useEffect(() => { | ||
const interval = setInterval(async () => { | ||
setFast((prev) => prev + 1) | ||
}, FAST_INTERVAL) | ||
return () => clearInterval(interval) | ||
}, []) | ||
|
||
useEffect(() => { | ||
const interval = setInterval(async () => { | ||
setSlow((prev) => prev + 1) | ||
}, SLOW_INTERVAL) | ||
return () => clearInterval(interval) | ||
}, []) | ||
|
||
return <RefreshContext.Provider value={{ slow, fast }}>{children}</RefreshContext.Provider> | ||
} | ||
|
||
export { RefreshContext, RefreshContextProvider } |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
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
Oops, something went wrong.