-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] [UI] Pools page and user liquidity #414
base: master
Are you sure you want to change the base?
Conversation
✨ Deployment complete! Take a peek over at https://703687ce.ui-storybook.pages.dev |
Deploying with Cloudflare Pages
|
const getUserAllocation = useCallback((poolSpec: PoolSpec) => { | ||
const pool = usePool(poolSpec.id); | ||
const { lpToken, userLpTokenAccount } = usePool(poolSpec.id); | ||
const userLpBalances = useUserLpBalances(lpToken, userLpTokenAccount); |
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.
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
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.
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
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.
@swimthor Thanks for taking the time to look! I will try with react component and see does it solve those issues. Thanks!
isExpandable={true} | ||
responsive={true} | ||
columns={columns} | ||
// sorting={sorting} |
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 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}
/>
Notion ticket: N/A
Checklist