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

react: add useProfilePrice hook #868

Closed
wants to merge 2 commits into from
Closed

Conversation

krzysu
Copy link
Contributor

@krzysu krzysu commented Feb 29, 2024

No description provided.

Copy link

changeset-bot bot commented Feb 29, 2024

🦋 Changeset detected

Latest commit: c91e6a2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@lens-protocol/domain Minor
@lens-protocol/react Minor
@lens-protocol/react-native Minor
@lens-protocol/react-web Minor
@lens-protocol/api-bindings Patch
@lens-protocol/blockchain-bindings Patch
@lens-protocol/wagmi Major
@lens-protocol/client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

height bot commented Feb 29, 2024

This pull request has been linked to 1 task:

💡Tip: Add "Close T-19450" to the pull request title or description, to a commit message, or in a comment to mark this task as "Done" when the pull request is merged.

Copy link

vercel bot commented Feb 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
lens-sdk-example-web-wagmi ✅ Ready (Inspect) Visit Preview May 17, 2024 9:20am

@@ -116,12 +116,5 @@
"web/index.ts"
],
"exports": true
},
"pnpm": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pnpm was complaining about this, it should be defined at the root of the monorepo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the intent was to not have this warning screaming at people using pnpm to install these packages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I don't know if this is effective if done on what, from the consumer perspective, is a dependency package.json

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this as pnpm complains, when running install with:

packages/gated-content                   |  WARN  The field "pnpm" was found in /lens-sdk/packages/gated-content/package.json. 
This will not take effect. You should configure "pnpm" at the root of the workspace instead.

import { PromiseResultPresenter } from '../../transactions/adapters/PromiseResultPresenter';
import { ProfilePriceGateway } from './ProfilePriceGateway';

export type ProfilePriceResult = ProfilePrices;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to alias it? The Result suffix could lead to confusion given the term is widely used in the context of Result<T, E>.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProfilePrices seems good to go out in the wild, it's DTO anyway.


void fetchData();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Copy link
Member

@cesarenaldi cesarenaldi Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just make it lazy at this point? data comes back as ProfilePriceResult as well as part of the lazy callback.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made it lazy, added also error handling

* @category Misc
* @group Hooks
*/
export function useProfilePrice(): ReadResult<ProfilePriceResult> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consolidate the use of plural/singular? Sometimes we say ProfilePrices, here it's singular.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it plural as we expect to add more currencies soon

useEffect(() => {
void execute();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only problem is here, if execute is provided in useEffect deps, then the app is stuck in a never-ending loop.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we brainstorm some options here? Seems a flaw in the way useDeferredTask is implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even if not perfect, I'd merge this branch as an example of onchain read hook, and keep it low profile, wdyt?

@cesarenaldi
Copy link
Member

Parking this one for now.

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