Skip to content

[WIP] [UI] Pools page and user liquidity#414

Draft
cyphertrace wants to merge 4 commits into
masterfrom
ui/user-liquidity
Draft

[WIP] [UI] Pools page and user liquidity#414
cyphertrace wants to merge 4 commits into
masterfrom
ui/user-liquidity

Conversation

@cyphertrace

Copy link
Copy Markdown
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

github-actions Bot commented Oct 4, 2022

Copy link
Copy Markdown

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

@cloudflare-workers-and-pages

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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}

@swimthor swimthor Oct 6, 2022

Copy link
Copy Markdown
Contributor

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