OktaWidget with ReactJs code - Redirection Issue

I am trying to use the Okta Widget to authenticate and redirect the User to a new Website from ReactJs code but it stops after the Authentication and doesn’t proceed with redirection.

Followed steps as mentioned in Okta guide URL:

However I am able to achieve the same functionality following the steps from below url but it did not use the Okta Widget.

Error: Tokens values are getting as undefined in “OnSuccess” function

You might want to check out this sample app which uses a self-hosted widget with React.

This is not working in my scenario. I am able to open the Okta Widget and Login but the redirection part seems to failing.
In the below code ‘res.tokens’ value is not available and my response obj consists of ‘session and user’ details.

{ el: widgetRef.current },
(res) => {
(err) => {
throw err;