Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
eb09894b
Unverified
Commit
eb09894b
authored
Sep 24, 2021
by
Zach Pomerantz
Committed by
GitHub
Sep 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(web3): render children while awaiting connection (#2400)
parent
bb3c7ddb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
29 deletions
+2
-29
index.tsx
src/components/Web3ReactManager/index.tsx
+2
-29
No files found.
src/components/Web3ReactManager/index.tsx
View file @
eb09894b
import
{
Trans
}
from
'
@lingui/macro
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useEffect
,
useState
}
from
'
react
'
import
{
useEffect
}
from
'
react
'
import
styled
from
'
styled-components/macro
'
import
{
network
}
from
'
../../connectors
'
import
{
NetworkContextName
}
from
'
../../constants/misc
'
import
{
useEagerConnect
,
useInactiveListener
}
from
'
../../hooks/web3
'
import
Loader
from
'
../Loader
'
const
MessageWrapper
=
styled
.
div
`
display: flex;
...
...
@@ -36,25 +35,8 @@ export default function Web3ReactManager({ children }: { children: JSX.Element }
// when there's no account connected, react to logins (broadly speaking) on the injected provider, if it exists
useInactiveListener
(
!
triedEager
)
// handle delayed loader state
const
[
showLoader
,
setShowLoader
]
=
useState
(
false
)
useEffect
(()
=>
{
const
timeout
=
setTimeout
(()
=>
{
setShowLoader
(
true
)
},
600
)
return
()
=>
{
clearTimeout
(
timeout
)
}
},
[])
// on page load, do nothing until we've tried to connect to the injected connector
if
(
!
triedEager
)
{
return
null
}
// if the account context isn't active, and there's an error on the network context, it's an irrecoverable error
if
(
!
active
&&
networkError
)
{
if
(
triedEager
&&
!
active
&&
networkError
)
{
return
(
<
MessageWrapper
>
<
Message
>
...
...
@@ -66,14 +48,5 @@ export default function Web3ReactManager({ children }: { children: JSX.Element }
)
}
// if neither context is active, spin
if
(
!
active
&&
!
networkActive
)
{
return
showLoader
?
(
<
MessageWrapper
>
<
Loader
/>
</
MessageWrapper
>
)
:
null
}
return
children
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment