useDynamicTokens
While you can have a cart and use the useTokens hook to display a grid of tokens, this hook is specifically designed to make it easier to use the cart in a token grid. The hook handles the following things:
- Sorting the tokens if a token in a dynamically priced pool is in the cart
- Automatically returning cart actions from the useCart hook
- Adding a
isInCart
boolean property to each token to make it easier to display which token is in the cart
import { useDynamicTokens } from '@reservoir0x/reservoir-kit-ui'
const { data: tokens, add, remove } = useDynamicTokens({
collection: "0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb",
})
//Display the tokens in your app
Updated almost 2 years ago