Skip to content

Reload of app on RouteNavItemΒ #25

@charlesfrancisco

Description

@charlesfrancisco

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions