# Okta-react 2.0 migration SecureRoute issues

**URL:** <https://devforum.okta.com/t/okta-react-2-0-migration-secureroute-issues/9607>\
**Category:** Questions\
**Created:** [June 2, 2020, 8:31pm UTC](https://devforum.okta.com/t/okta-react-2-0-migration-secureroute-issues/9607 "2020-06-02T20:31:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jchabot86](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jchabot86](https://devforum.okta.com/u/jchabot86)\
**Post date:** [June 2, 2020, 8:31pm UTC](https://devforum.okta.com/t/okta-react-2-0-migration-secureroute-issues/9607/1 "2020-06-02T20:31:33Z")

</div>

We are following the migration steps for okta-react outlined in the README provided by okta as we upgrade from 1.x to 2.x. We are now noticing some strange behavior with SecureRoute. We wrap our entire secured application with:

`<SecureRoute component={AuthenticatedPages}/>`

Inside there we have an additional switch with more SecureRoute’s. We notice that anytime we switch routes within the Authenticated portion of our application, that the AuthenticatedPages component is totally unmounting and re-mounting, causing all state to be lost and executing functionality that previously only executed the first time that the authenticated area loaded/mounted.

Any insight?

---

<div class="post-metadata">

**Author:** ![jchabot86](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jchabot86](https://devforum.okta.com/u/jchabot86)\
**Post date:** [June 3, 2020, 4:17pm UTC](https://devforum.okta.com/t/okta-react-2-0-migration-secureroute-issues/9607/2 "2020-06-03T16:17:59Z")

</div>

I did notice that if I switch that parent component from a SecureRoute to just Route then it does seem to alleviate the issue a bit since all the child routes are SecureRoute’s. Not sure if this the way to go though with this.

---

<div class="post-metadata">

**Author:** ![jchabot86](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jchabot86](https://devforum.okta.com/u/jchabot86)\
**Post date:** [June 3, 2020, 5:47pm UTC](https://devforum.okta.com/t/okta-react-2-0-migration-secureroute-issues/9607/3 "2020-06-03T17:47:01Z")

</div>

I believe this also could be related to [https://github.com/okta/okta-oidc-js/issues/777](https://github.com/okta/okta-oidc-js/issues/777)

---

<div class="post-metadata">

**Author:** ![jchabot86](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jchabot86](https://devforum.okta.com/u/jchabot86)\
**Post date:** [June 11, 2020, 1:30pm UTC](https://devforum.okta.com/t/okta-react-2-0-migration-secureroute-issues/9607/4 "2020-06-11T13:30:37Z")

</div>

any guidance here would be greatly appreciated! am willing to talk it through as well!

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [January 24, 2024, 8:01pm UTC](https://devforum.okta.com/t/okta-react-2-0-migration-secureroute-issues/9607/5 "2024-01-24T20:01:44Z")

</div>

Closed on January 24, 2024, 8:01pm UTC


