-
Notifications
You must be signed in to change notification settings - Fork 312
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
Component State fails to reset on route change following AWS Amplify withAuthenticator implementation #5046
Comments
Hi @skims-ella-travelstead, Please let me know if this solves your issue. |
Hi @reesscot Thank you so much for the response! I want to preface that I am fairly new to React in general so apologize if i get some of this confused. I tried the example code on the repo you provided and the problem is when I nest App.tsx (added
main.tsx
The state don't refresh for MyPage. I did figure this out by using My initial
The rest of the files stayed the same. But I am not sure if that is also advisable set-up. If this is out scope of Amplify, I totally understand and we can close this. |
@skims-ella-travelstead I think the way you are doing it now by conditionally rendering your PrivateRouter based on authentication status makes sense. I'll close this out now since it seems like your question was answered. Please let us know if you have any further issues! |
Before creating a new issue, please confirm:
On which framework/platform are you having an issue?
React
Which UI component?
Authenticator
How is your app built?
Create React App (with Typescript)
What browsers are you seeing the problem on?
Chrome
Which region are you seeing the problem in?
us-east-2
Please describe your bug.
Hello,
We are in the middle of integrating AWS Cognito to our React App and encountered an issue where component state does not seem to reset after navigating to a route.
The app is created with:
Create React App (with Typescript)
aws-amplify/ui-react": "^6.1.5"
"aws-amplify": "^6.0.19"
"react": "^18.2.0"
"react-router-dom": "^6.22.2"
What's the expected behaviour?
The component state resets when navigating to the route.
Help us reproduce the bug!
Steps to reproduce:
User signs in using AWS Cognito + Amplify UI (withAuthenticator component)
User search for a keyword, this is where states dont seem to reset
It works fine when you enter the keyword in the URL bar (refreshes page), but not when entering the keyword on the search bar.
Code Snippet
App.tsx
Navbar.tsx
Search.tsx
MyPage.tsx
index.tsx
Console log output
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: