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

Allow a custom navigate to be provided to the Provider #293

Merged
merged 1 commit into from
Oct 27, 2023
Merged

Conversation

jasong689
Copy link
Contributor

@jasong689 jasong689 commented Oct 23, 2023

By default our components that control navigation SignInOrRedirect/SignOutOrRedirect use window.location. This causes window reloads and flashes of unstyled content. We can't make assumptions about an app's routing system, so we should allow consumers to pass in a custom navigate function that we'll use.

PR Checklist

  • Important or complicated code is tested
  • Any user facing changes are documented in the Gadget-side changelog
  • Any immediate changes are slated for release in Gadget via a generated package dependency bump
  • Versions within this monorepo are matching and there's a valid upgrade path

@jasong689 jasong689 requested review from infiton and airhorns October 24, 2023 15:32
@jasong689 jasong689 marked this pull request as ready for review October 24, 2023 15:33
@infiton
Copy link
Contributor

infiton commented Oct 24, 2023

what would the provider setup look like in this case? Just so I can see what our template code will look like

@jasong689
Copy link
Contributor Author

jasong689 commented Oct 24, 2023

for react-router-dom it would be

const navigate = useNavigate();

<Provider api={api} navigate={navigate} auth={window.gadgetConfig.authentication}>
</Provider>

Copy link
Contributor

@infiton infiton left a comment

Choose a reason for hiding this comment

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

great

@jasong689 jasong689 merged commit 0a375d0 into main Oct 27, 2023
8 checks passed
@jasong689 jasong689 deleted the ggt-5050 branch October 27, 2023 14:13
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