-
Notifications
You must be signed in to change notification settings - Fork 25
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
fix: make all hooks use the same return type definition #85
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Coverage report
Test suite run success23 tests passing in 3 suites. Report generated by 🧪jest coverage report action from 663a8cf |
LuizAsFight
approved these changes
May 28, 2024
LuizAsFight
pushed a commit
that referenced
this pull request
Jun 4, 2024
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @fuels/react@0.21.0 ### Minor Changes - Created useContractRead hook to read contract data from a contract instance or from a contract id. If provided Abi is declared with `as const`, hook will dynamically infer possible method names, as well as the arguments quantity and types for a selected method, by [@arthurgeron](https://github.com/arthurgeron) (See [#91](#91)) - - Add `useTransactionResult` hook to get a transaction that has been executed - Create a type `UseNamedQueryParams` to allow overriding `select` function of TanStack Query and our custom `name` property. ### Basic usage with `select` function ````tsx const { receipts } = useTransactionResult({ txId: '0xd7ad974cdccac8b41132dfe1d2a4219a681af1865f0775f141c4d6201ee428d1', query: { name: 'receipts', // Or anything else (optional, default: 'transactionResult') select: (data) => data?.receipts || null, }, }); ```, by [@helciofranco](https://github.com/helciofranco) (See [#94](#94)) ```` - Adds mutation callbacks, such as `onError` and `onSuccess`, by [@helciofranco](https://github.com/helciofranco) (See [#97](#97)) - Provide consistent return types across Fuel hooks, for an easier typed experience. Every query hook will now return a `null` value if the query is not available, instead of `undefined`. ### Examples ````tsx const { wallet } = useWallet(); // wallet is Wallet | null const { network } = useNetwork(); // network is Network | null // and so on... Every query hook will return T | null ```, by [@helciofranco](https://github.com/helciofranco) (See [#85](#85)) ```` - Add `useSendTransaction` hook that allows developers to easily send a transaction. ````tsx const { sendTransaction } = useSendTransaction(); // [...] const transactionRequest = new ScriptTransactionRequest({}); // Or any other tx request sendTransaction({ address: 'fuel1zs7l8ajg0qgrak3jhhmq3xf3thd8stu535gj7p5fye2578yccjyqcgja3z', transaction, }); ```, by [@helciofranco](https://github.com/helciofranco) (See [#92](#92)) ```` ## @fuels/playwright-utils@0.21.0 ### Patch Changes - update wallet version to 0.21.0, by [@LuizAsFight](https://github.com/LuizAsFight) (See [#98](#98)) ## @fuels/assets@0.21.0 ## @fuels/changeset@0.21.0 ## @fuels/eslint-plugin@0.21.0 ## @fuels/jest@0.21.0 ## @fuels/local-storage@0.21.0 ## @fuels/prettier-config@0.21.0 ## @fuels/react-xstore@0.21.0 ## @fuels/ts-config@0.21.0 ## @fuels/tsup-config@0.21.0 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
From now on, our hooks will return
T | null
, instead ofT | undefined | null
.Most of them were already return only the
T | null
, I've just fixed the missing ones.Examples