AnomalyInnovations / serverless-stack-demo-client

Source for the demo app client in the Serverless Stack Guide
https://demo2.serverless-stack.com
MIT License
635 stars 204 forks source link

Reload of app on RouteNavItem #25

Open charlesfrancisco opened 6 years ago

charlesfrancisco commented 6 years ago

Hello, Thanks for a great tutorial. For those who want to use the components in an application, I have noticed a small glitch on the RouteNavItem component: The onclick is overriden without a preventDefault which leads to both a standard navigation on the link and get on the server as well as the history push. This causes the page to be loaded as well, loosing the AWS.config.credentials, leading to a retrieval of the credentials from storage and refresh of the token at every navigation from a navbar link plus aborted APIG calls as the page reloads while executing. On the current app this effect is limited as navigations are mostly programmatic (e.g. login page redirect to home, note detail opening/editing) but can still be noted from a note, navigating to the home page. For expanded apps with several menus with APIG initial loading, the effect will be far more noticeable with APIG

alert messages popping out and a luggish load of the containers (done twice).

I would suggest the following change on RouteNavItems.js (12):

    onClick={e => {e.preventDefault(); history.push(e.currentTarget.getAttribute("href"));}}

only the push is executed, removing issues of server back and forth and aborted APIG calls. Hope it helps. Cheers, Charles

jayair commented 6 years ago

@charlesfrancisco I'm guessing there was an update to one of the dependencies. Since this wasn't an issue before - https://demo.serverless-stack.com. Can you share your package.json so I can check what is going on?