[WIP] [UI] Pools page and user liquidity#414
Draft
cyphertrace wants to merge 4 commits into
Draft
Conversation
|
✨ Deployment complete! Take a peek over at https://703687ce.ui-storybook.pages.dev |
Deploying with
|
| Latest commit: |
af8784e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f2ce4fb5.swim-ui.pages.dev |
| Branch Preview URL: | https://ui-user-liquidity.swim-ui.pages.dev |
swimthor
reviewed
Oct 6, 2022
| const getUserAllocation = useCallback((poolSpec: PoolSpec) => { | ||
| const pool = usePool(poolSpec.id); | ||
| const { lpToken, userLpTokenAccount } = usePool(poolSpec.id); | ||
| const userLpBalances = useUserLpBalances(lpToken, userLpTokenAccount); |
Contributor
There was a problem hiding this comment.
The root cause is we are using hook inside a callback
Warning: React has detected a change in the order of Hooks called by PoolsPage. This will lead to bugs and errors if not fixed. For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks
Contributor
There was a problem hiding this comment.
One solution for this is to create a custom react component and run this function as hook there, and use that component in columns.render
Contributor
Author
There was a problem hiding this comment.
@swimthor Thanks for taking the time to look! I will try with react component and see does it solve those issues. Thanks!
swimthor
reviewed
Oct 6, 2022
| isExpandable={true} | ||
| responsive={true} | ||
| columns={columns} | ||
| // sorting={sorting} |
Contributor
There was a problem hiding this comment.
I can make the sorting work on local, eui actually does not handle the sorting logic for us, so we have to save the sort direction and field manually and do the sorting ourselves.
const [sortField, setSortField] = useState<keyof typeof tablePools[0]>('id');
const [sortDirection, setSortDirection] = useState<Direction>('asc');
const onTableChange = useCallback(({sort }: Criteria<typeof tablePools[0]>): void => {
if (sort !== undefined) {
setSortField(sort.field);
setSortDirection(sort.direction);
}
});
// somewhere we sort `tablePools` by sortField and sortDirection
<EuiBasicTable
......
sorting={{
sort: {
field: sortField,
direction: sortDirection,
},
enableAllColumns: true,
}}
onChange={onTableChange}
/>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Notion ticket: N/A
Checklist