-
Notifications
You must be signed in to change notification settings - Fork 14
refactor(context): Split ApiContext into Api & SystemContext #120
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,12 +26,12 @@ export function Balance(props: BalanceProps): React.ReactElement { | |
orientation = 'horizontal', | ||
...rest | ||
} = props; | ||
const { api, isReady } = useContext(ApiContext); | ||
const { api, isApiReady } = useContext(ApiContext); | ||
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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 commentThe 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 |
||
const balanceSub = combineLatest([ | ||
api.derive.balances.all(address), | ||
api.derive.staking.account(address), | ||
|
@@ -42,7 +42,7 @@ export function Balance(props: BalanceProps): React.ReactElement { | |
|
||
return (): void => balanceSub.unsubscribe(); | ||
} | ||
}, [api, isReady, address]); | ||
}, [api, isApiReady, address]); | ||
|
||
const handleRedeem = (address: string): void => { | ||
// FIXME We're not unsubscring here, we should | ||
|
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.
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....