# React SecureRoute render behavior

**URL:** <https://devforum.okta.com/t/react-secureroute-render-behavior/8794>\
**Category:** Questions\
**Created:** [April 7, 2020, 6:16pm UTC](https://devforum.okta.com/t/react-secureroute-render-behavior/8794 "2020-04-07T18:16:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jspurgeon](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@jspurgeon](https://devforum.okta.com/u/jspurgeon)\
**Post date:** [April 7, 2020, 6:16pm UTC](https://devforum.okta.com/t/react-secureroute-render-behavior/8794/1 "2020-04-07T18:16:48Z")

</div>

SecureRoute in @okta/okta-react 2.0.0 is not working as a Route should using the render attribute. Using the sample application from here [GitHub - okta/samples-js-react: React Auth SDK sample](https://github.com/okta/samples-js-react), if you change the line in app.jsx from

to

\<SecureRoute path="/profile" render={(routeProps) =\> \<Profile {…routeProps} /\>}

It will not redirect you the login page.

---

<div class="post-metadata">

**Author:** ![farjang](https://avatars.discourse-cdn.com/v4/letter/f/f05b48/32.png) [@farjang](https://devforum.okta.com/u/farjang)\
**Post date:** [May 11, 2020, 5:34pm UTC](https://devforum.okta.com/t/react-secureroute-render-behavior/8794/2 "2020-05-11T17:34:46Z")

</div>

I am getting the same issue, it won’t redirect to login when use render function vs component. Will this be fix?

---

<div class="post-metadata">

**Author:** ![sshort](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sshort](https://devforum.okta.com/u/sshort)\
**Post date:** [May 21, 2020, 2:18am UTC](https://devforum.okta.com/t/react-secureroute-render-behavior/8794/3 "2020-05-21T02:18:30Z")

</div>

I am seeing the same issue. Are there any plans to fix this? It is preventing my project from upgrading to the current version 3.0.1

---

<div class="post-metadata">

**Author:** ![justin-dsg](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@justin-dsg](https://devforum.okta.com/u/justin-dsg)\
**Post date:** [June 22, 2020, 4:07pm UTC](https://devforum.okta.com/t/react-secureroute-render-behavior/8794/4 "2020-06-22T16:07:39Z")

</div>

I got around this by replacing the render={() =\> xxx} call with component={Xxx}.

You can simply define Xxx up above, and that way you can pass in all the props you need, and still call it using the component prop.

Example:

```
const Portfolio = () => (
    <PortfolioPage
      positions={state.history.positions}
      history={state.history}
    />
  );

<Router>
      <Security
        issuer={config.okta.issuer}
        clientId={config.okta.client_id}
        redirectUri={config.okta.redirect_uri}
        onAuthRequired={onAuthRequired}
        pkce={true}
      >
        <SecureRoute exact path="/portfolio" component={Portfolio} />
      </Security>
</Router>
```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [April 25, 2022, 5:09pm UTC](https://devforum.okta.com/t/react-secureroute-render-behavior/8794/5 "2022-04-25T17:09:56Z")

</div>

Closed on April 25, 2022, 5:09pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
