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

feat(elements): Add temporary useIsLoading hook #2751

Merged
merged 12 commits into from
Feb 14, 2024

Conversation

LekoArts
Copy link
Member

@LekoArts LekoArts commented Feb 7, 2024

Description

While in #2669 Bryce started implementing a holistic solution, for the Alpha stage we'll opt to providing a temporary unstable_useIsLoading hook. Took some bits from #2669 that were useful in any way 👍

Once we have thought more about the API for loading states we'll remove this again and tackle the proper solution.

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Packages affected

  • @clerk/backend
  • @clerk/chrome-extension
  • @clerk/clerk-js
  • @clerk/clerk-expo
  • @clerk/fastify
  • gatsby-plugin-clerk
  • @clerk/localizations
  • @clerk/nextjs
  • @clerk/clerk-react
  • @clerk/remix
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/themes
  • @clerk/types
  • build/tooling/chore

Copy link

changeset-bot bot commented Feb 7, 2024

🦋 Changeset detected

Latest commit: 4b0d0c0

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

@LekoArts LekoArts requested a review from tmilewski February 7, 2024 13:38
@LekoArts LekoArts added this to the @clerk/elements (Alpha) milestone Feb 7, 2024
@LekoArts LekoArts mentioned this pull request Feb 7, 2024
24 tasks
@LekoArts LekoArts marked this pull request as ready for review February 7, 2024 15:36
* Caution: This hook is unstable and may disappear in the future.
* This is a temporary hook until the actual loading API is explored and implemented.
*/
export const unstable_useIsLoading = () => {
Copy link
Member

Choose a reason for hiding this comment

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

To keep with React hook naming conventions:

Suggested change
export const unstable_useIsLoading = () => {
export const useIsLoading_unstable = () => {


const isGlobalLoading = startLoading || firstFactorLoading || secondFactorLoading;

return [isGlobalLoading, { start: startLoading, firstFactor: firstFactorLoading, secondFactor: secondFactorLoading }];
Copy link
Member

Choose a reason for hiding this comment

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

Likely a cleaner/clearer way to handle this in the long-run, but cool for now. On concern though is that it's specific to signIn, and lives in the root React hooks. Mind moving it over?

@LekoArts LekoArts added this pull request to the merge queue Feb 14, 2024
Merged via the queue into main with commit dc3dcc6 Feb 14, 2024
7 checks passed
@LekoArts LekoArts deleted the lekoarts/sdk-1294-loading-hook-as-a-test branch February 14, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants