-
Notifications
You must be signed in to change notification settings - Fork 14
refactor(context): Split ApiContext into Api & SystemContext #120
Conversation
front/context/src/SystemContext.tsx
Outdated
@@ -0,0 +1,152 @@ | |||
// Copyright 2018-2020 @paritytech/substrate-light-ui authors & contributors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
@@ -24,7 +23,7 @@ export function ContextGate({ | |||
<AccountsContextProvider> | |||
<TxQueueContextProvider> | |||
<ApiContextProvider provider={new WsProvider(ARCHIVE_NODE_ENDPOINT)}> | |||
<StakingContextProvider>{children}</StakingContextProvider> | |||
<>{children}</> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<>{children}</> | |
{children} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, i get some error like https://github.com/paritytech/substrate-light-ui/pull/743/files#diff-418f37370656dbd0c860458c05c4933cR17
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, i guess that makes sense....
const [allBalances, setAllBalances] = useState(); | ||
const [allStaking, setAllStaking] = useState(); | ||
|
||
useEffect(() => { | ||
if (isReady) { | ||
if (isApiReady) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it weird that we have to do this everywhere, since none of these should load in the first place before the isApiReady
is set to true in the ContextGate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since none of these should load in the first place before the isApiReady is set to true in the ContextGate
Hmm, if we put this in ui-components and expose this package to npm, then I don't think we should assume that the end-user will user this component inside a ContextGate when isApiReady is set to true. Just to be sure, I'd leave this check here.
In light-ui, if we use internal components that are behind a Gate, then yeah we can remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: but also, as we talked before, a better way would simply only expose pure/stateless components in ui-components
needed for paritytech/substrate-light-ui#743
currentAccount
(related Proposal: Move MatchParams.currentAccount logic to UserContext substrate-light-ui#415)