Skip to content
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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

cyphertrace
Copy link
Contributor

Notion ticket: N/A

Checklist

  • Github project and label have been assigned
  • Tests have been added or are unnecessary
  • Docs have been updated or are unnecessary
  • Preview deployment works (visit the Cloudflare preview URL)
  • Manual testing in #product-testing completed or unnecessary
  • New i18n strings do not contain any security vulnerabilities (e.g. should not allow translator to update email/url)
  • When fetching new translations from external sources, do a sanity check (e.g. get people who speak the language to check, shove all new translations into Google translate)

@github-actions
Copy link

github-actions bot commented Oct 4, 2022

✨ Deployment complete! Take a peek over at https://703687ce.ui-storybook.pages.dev

@cloudflare-workers-and-pages
Copy link

Deploying with  Cloudflare Pages  Cloudflare Pages

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

View logs

const getUserAllocation = useCallback((poolSpec: PoolSpec) => {
const pool = usePool(poolSpec.id);
const { lpToken, userLpTokenAccount } = usePool(poolSpec.id);
const userLpBalances = useUserLpBalances(lpToken, userLpTokenAccount);
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

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}
Copy link
Contributor

@swimthor swimthor Oct 6, 2022

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}
    />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants